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


 
Thread Tools Search this Thread
Top Forums Programming Compiling C++ code with NetCDF libraries: "undefined reference"
# 1  
Old 09-21-2012
Compiling C++ code with NetCDF libraries: "undefined reference"

Hi!

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.cppSmilie.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!

Cheers,
Chris

/usr/share/man/man3/netcdf.3.gz
/usr/share/man/man3/netcdf_f77.3.gz
/usr/share/man/man3/netcdf_f90.3f90.gz
/usr/share/doc/netcdf-bin
/usr/share/doc/libnetcdf-dev
/usr/share/doc/libnetcdf6
/usr/share/mime/application/x-netcdf.xml
/usr/lib/libnetcdf_c++.so
/usr/lib/libnetcdff.so
/usr/lib/libnetcdf.a
/usr/lib/netcdf.pc
/usr/lib/pkgconfig/netcdf.pc
/usr/lib/libnetcdf.so.6.0.0
/usr/lib/libnetcdff.so.5.0.0
/usr/lib/libnetcdf.so.6
/usr/lib/libnetcdf_c++.so.5
/usr/lib/libnetcdf.so
/usr/lib/libnetcdf_c++.a
/usr/lib/libnetcdff.so.5
/usr/lib/libnetcdff.a
/usr/lib/libnetcdf_c++.so.5.0.0
/usr/include/netcdf.mod
/usr/include/netcdf.h
/usr/include/hdf/hdf2netcdf.h
/usr/include/hdf/hdf4_netcdf.h
/usr/include/netcdf.hh
/usr/include/netcdf.inc
/usr/include/netcdfcpp.h
/usr/local/lib/libnetcdf_c++4.la
/usr/local/lib/pkgconfig/netcdf-cxx4.pc
/usr/local/lib/libnetcdf_c++4.so
/usr/local/lib/libnetcdf_c++4.so.1.0.2
/usr/local/lib/libnetcdf_c++4.a
/usr/local/lib/ncarg/data/cdf/sst30e_netcdf.nc
/usr/local/lib/ncarg/data/cdf/sstdata_netcdf.nc
/usr/local/lib/libnetcdf_c++4.so.1
/usr/local/include/netcdf
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Emergency UNIX and Linux Support

Perl error: Can't call method "value" on an undefined value

Hi, I am running a perl script to automate a process and I keep running into a error can't find the "value" Can't call method "value" on an undefined value at process_file.pl line 44. file is CVS cell is ifdfdxrfmp.ksh Here is the script I have also attached it as well: ... (2 Replies)
Discussion started by: vpundit
2 Replies

3. Solaris

I got "undefined reference to" on gcc

Hell all I tryed to build rmp from sources on Solaris 10. I download source code, install gcc, binutils, and other packs с sunfreeware.com. Doring compilation I got an error: /bin/bash ./libtool --tag=CC --mode=link gcc -std=gnu99 -g -O2 -fPIC -DPIC -D_REENTRANT -Wall... (0 Replies)
Discussion started by: sluge
0 Replies

4. Programming

make fails with "undefined reference to..."

i am compiling a program called vasp on suse and get the following error. there are many more preprocess and ifort commands prior so i just grabbed the tail of the log file: ./preprocess <main.F | /usr/bin/cpp -P -C -traditional >main.f90 -DMPI -DHOST=\"LinuxIFC\" -DIFC -Dkind8 -DNGZhalf... (6 Replies)
Discussion started by: crimso
6 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Undefined "n" value and simplifying script

I have a very 'dirty' bash script that is working and looks like this: #!/bin/bash for i in {1..n} do mv block${i} infile ./dnadist <<-EOF D Y EOF rm infile mv outfile Result${i} mv Result${i} infile ./neighbor <<-EOF Y EOF rm infile rm outfile mv outtree Result${i}... (8 Replies)
Discussion started by: Xterra
8 Replies

7. Shell Programming and Scripting

bash: "undefined variable" and pipe

Hi, haven't found anything about this through searching, so may be a new topic: when doing this: set -o nounset set -o errexit find . -name "*.lib" | while read library; do echo ${libary} done echo "after while" I expect the script to exit within the while loop (because of nounset and... (6 Replies)
Discussion started by: nagaidhlig
6 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

9. AIX

Getting error "Undefined symbol: .u_strlen_2_6"

Hi, I am using xlC compiler. The compilation goes fine but at the time of linking it gives the following error ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. ld: 0711-317 ERROR: Undefined symbol: .u_strlen_2_6 ld: 0711-317 ERROR: Undefined symbol:... (0 Replies)
Discussion started by: nachiketv
0 Replies

10. Programming

shared object "undefined symbol: fstat" error

Didn't have this problem in AIX, but ported to Linux with GCC compiler and am now getting a runtime error: tssutil: symbol lookup error: /work/agility/devel/bin/libagam.so: undefined symbol: fstat I'm sure most of you know that fstat is an intrinsic function just like printf, memcpy, etc. When I... (5 Replies)
Discussion started by: marcus121
5 Replies
Login or Register to Ask a Question