Sponsored Content
Top Forums Programming Compiling C++ code with NetCDF libraries: "undefined reference" Post 302704385 by Alauda on Friday 21st of September 2012 01:26:24 PM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

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

8. 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

9. 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

10. 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
LDCONFIG(8)						     Linux Programmer's Manual						       LDCONFIG(8)

NAME
ldconfig - configure dynamic linker run-time bindings SYNOPSIS
/sbin/ldconfig [-nNvXV] [-f conf] [-C cache] [-r root] directory... /sbin/ldconfig -l [-v] library... /sbin/ldconfig -p DESCRIPTION
ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories, /lib and /usr/lib (on some 64-bit architectures such as x86-64, lib and /usr/lib are the trusted directories for 32-bit libraries, while /lib64 and /usr/lib64 are used for 64-bit libraries). The cache is used by the run-time linker, ld.so or ld-linux.so. ldconfig checks the header and filenames of the libraries it encounters when determining which versions should have their links updated. ldconfig will attempt to deduce the type of ELF libraries (i.e., libc5 or libc6/glibc) based on what C libraries, if any, the library was linked against. Some existing libraries do not contain enough information to allow the deduction of their type. Therefore, the /etc/ld.so.conf file format allows the specification of an expected type. This is used only for those ELF libraries which we can not work out. The format is "dirname=TYPE", where TYPE can be libc4, libc5, or libc6. (This syntax also works on the command line.) Spaces are not allowed. Also see the -p option. ldconfig should normally be run by the superuser as it may require write permission on some root owned directories and files. OPTIONS
-c fmt, --format=fmt (Since glibc 2.2) Cache format to use: old, new, or compat (default). -C cache Use cache instead of /etc/ld.so.cache. -f conf Use conf instead of /etc/ld.so.conf. -i, --ignore-aux-cache (Since glibc 2.7) Ignore auxiliary cache file. -l (Since glibc 2.2) Library mode. Manually link individual libraries. Intended for use by experts only. -n Process only the directories specified on the command line. Don't process the trusted directories, nor those specified in /etc/ld.so.conf. Implies -N. -N Don't rebuild the cache. Unless -X is also specified, links are still updated. -p, --print-cache Print the lists of directories and candidate libraries stored in the current cache. -r root Change to and use root as the root directory. -v, --verbose Verbose mode. Print current version number, the name of each directory as it is scanned, and any links that are created. Overrides quiet mode. -V, --version Print program version. -X Don't update links. Unless -N is also specified, the cache is still rebuilt. FILES
/lib/ld.so Run-time linker/loader. /etc/ld.so.conf File containing a list of directories, one per line, in which to search for libraries. /etc/ld.so.cache File containing an ordered list of libraries found in the directories specified in /etc/ld.so.conf, as well as those found in the trusted directories. SEE ALSO
ldd(1), ld.so(8) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. GNU
2017-09-15 LDCONFIG(8)
All times are GMT -4. The time now is 04:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy