Unix/Linux Go Back    

Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Compiling C++ code with NetCDF libraries: "undefined reference"


Closed Linux or Unix Question    
Thread Tools Search this Thread Display Modes
Old Unix and Linux 09-21-2012
Alauda Alauda is offline
Registered User
Join Date: Sep 2012
Last Activity: 21 September 2012, 3:17 PM EDT
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Compiling C++ code with NetCDF libraries: "undefined reference"


I am trying to compile a C++ code with cmake and gcc on Ubuntu. The code uses NetCDF4 libraries. I specify the path to these libraries as follows:

-I/usr/local/include -L/usr/local/lib -lnetcdf -lnetcdf_c++4

"ccmake" and "cmake" work fine. After typing "make" I receive the error message:

Linking CXX executable guess
CMakeFiles/guess.dir/modules/guessio_daily_netCDF.cpp.o: In function `getYearlyRecord(Coord, double*, xtring, int)':
guessio_daily_netCDF.cppLinux.text+0x8309): undefined reference to `netCDF::NcFile::NcFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, netCDF::NcFile::FileMode)'

I receive the same message when I specify the path to my NetCDF4 libraries with a not-existing path (e.g. -I/blablabla/include ...). As I understand, the linker does not find my NetCDF libraries, correct? Do you have any suggestions on how to solve this problem? In case it helps, below I include the paths of all my netcdf libraries. The libraries were built with the same compiler (gcc). Thank you very much in advance!


Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl error: Can't call method "value" on an undefined value vpundit Emergency UNIX and Linux Support 2 07-21-2012 06:00 PM
I got "undefined reference to" on gcc sluge Solaris 0 07-09-2012 05:57 AM
make fails with "undefined reference to..." crimso Programming 6 10-19-2011 11:03 AM
Getting error "Undefined symbol: .u_strlen_2_6" nachiketv AIX 0 06-05-2006 10:16 AM
shared object "undefined symbol: fstat" error marcus121 Programming 5 04-24-2006 08:11 PM

All times are GMT -4. The time now is 12:28 PM.