NCAR / lrose-core

Core C/C++ code for LROSE.
https://www.eol.ucar.edu/content/lidar-radar-open-software-environment
Other
92 stars 51 forks source link

Undefined reference to Nc3File and Hdf5xx functions #15

Closed rpelorosso closed 7 years ago

rpelorosso commented 7 years ago

Hi!

I'm trying to compile lrose from source, I'm following the instructions from README_NCAR_BUILD.md

I've already installed lrose-netcdf following the instructions from README_NETCDF_BUILD.md

When compiling the apps, it fails indicating undefined references to functions in Nc3File:

/home/silencer/lrose-build/lib/libMdv.a(Mdv2NcfTrans.o): In function `Mdv2NcfTrans::_closeNcFile()':
Mdv2NcfTrans.cc:(.text+0x1fe): undefined reference to `Nc3File::close()'
/home/silencer/lrose-build/lib/libMdv.a(Mdv2NcfTrans.o): In function `Mdv2NcfTrans::_openNcFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
Mdv2NcfTrans.cc:(.text+0x3a7): undefined reference to `Nc3File::Nc3File(char const*, Nc3File::FileMode, unsigned long*, unsigned long, Nc3File::FileFormat)'
Mdv2NcfTrans.cc:(.text+0x3b3): undefined reference to `Nc3File::is_valid() const'
Mdv2NcfTrans.cc:(.text+0x5a3): undefined reference to `Nc3Error::Nc3Error(Nc3Error::Behavior)'
/home/silencer/lrose-build/lib/libMdv.a(Mdv2NcfTrans.o): In function `Mdv2NcfTrans::_addGlobalAttributes()':
Mdv2NcfTrans.cc:(.text+0x6f9): undefined reference to `Nc3File::add_att(char const*, char const*)'
Mdv2NcfTrans.cc:(.text+0x748): undefined reference to `Nc3File::add_att(char const*, char const*)'
Mdv2NcfTrans.cc:(.text+0x762): undefined reference to `Nc3File::add_att(char const*, char const*)'
Mdv2NcfTrans.cc:(.text+0x780): undefined reference to `Nc3File::add_att(char const*, char const*)'
Mdv2NcfTrans.cc:(.text+0x827): undefined reference to `Nc3File::add_att(char const*, char const*)'
/home/silencer/lrose-build/lib/libMdv.a(Mdv2NcfTrans.o):Mdv2NcfTrans.cc:(.text+0x84f): more undefined references to `Nc3File::add_att(char const*, char const*)' follow
...

and to Hdf5xx:

/home/silencer/lrose-build/lib/libRadx.a(GamicHdf5RadxFile.o): In function `GamicHdf5RadxFile::_readRootHow(H5::Group&)':
GamicHdf5RadxFile.cc:(.text+0xe7e): undefined reference to `Hdf5xx::DecodedAttr::DecodedAttr()'
GamicHdf5RadxFile.cc:(.text+0xee0): undefined reference to `Hdf5xx::loadAttribute(H5::H5Location&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Hdf5xx::DecodedAttr&)'
GamicHdf5RadxFile.cc:(.text+0xf29): undefined reference to `Hdf5xx::DecodedAttr::getAsDouble()'
GamicHdf5RadxFile.cc:(.text+0xf84): undefined reference to `Hdf5xx::loadAttribute(H5::H5Location&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Hdf5xx::DecodedAttr&)'
GamicHdf5RadxFile.cc:(.text+0xfcd): undefined reference to `Hdf5xx::DecodedAttr::getAsDouble()'
GamicHdf5RadxFile.cc:(.text+0x1028): undefined reference to `Hdf5xx::loadAttribute(H5::H5Location&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Hdf5xx::DecodedAttr&)'
GamicHdf5RadxFile.cc:(.text+0x1069): undefined reference to `Hdf5xx::DecodedAttr::getAsString[abi:cxx11]()'
GamicHdf5RadxFile.cc:(.text+0x114c): undefined reference to `Hdf5xx::loadAttribute(H5::H5Location&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Hdf5xx::DecodedAttr&)'
GamicHdf5RadxFile.cc:(.text+0x118d): undefined reference to `Hdf5xx::DecodedAttr::getAsString[abi:cxx11]()'
...

The compiler seems to be linking to the proper libraries. This log is for when I try to compile Tstorms2GenPoly:

make[1]: Entering directory '/home/silencer/lrose-source/lrose-core/codebase/apps/titan/src/Tstorms2GenPoly'
echo Making C++ program ... ; \
make _CC="gcc" _CPPC="g++" _FC="gfortran" DBUG_OPT_FLAGS="-g" DEBUG_CFLAGS="" DEBUG_LIBS="" DEBUG_LDFLAGS="" SYS_LIBS="" SYS_CFLAGS=" -DLINUX_64 -D_BSD_TYPES -DF_UNDERSCORE2 " Tstorms2GenPoly;
Making C++ program ...
make[2]: Entering directory '/home/silencer/lrose-source/lrose-core/codebase/apps/titan/src/Tstorms2GenPoly'
echo Linking C++ program ...
Linking C++ program ...
LD_LIBRARY_PATH=/home/silencer/lrose-build/lib:::
/bin/rm -f Tstorms2GenPoly
g++ -g -o Tstorms2GenPoly \
                  Params.o Args.o Tstorms2GenPoly.o Main.o    -L/home/silencer/lrose-build/lib -L/home/silencer/lrose-build/lib  -Wl,-rpath,/usr/local/netcdf4/lib -L/opt/netcdf4/lib -L/usr/local/netcdf4/lib -L/usr/local/lib  -Wl,-rpat
h,/usr/local/hdf5/lib -L/opt/hdf5/lib -L/usr/local/hdf5/lib  -Wl,-rpath,/usr/local/szip/lib -L/opt/szip/lib -L/usr/local/szip/lib  -Wl,-rpath,/usr/local/zlib/lib -L/opt/zlib/lib -L/usr/local/zlib/lib  -Wl,-rpath,/usr/local/udunits2/li
b -L/opt/udunits2/lib -L/usr/local/udunits2/lib  -Wl,-rpath,/usr/local/zlib/lib -L/opt/zlib/lib -L/usr/local/zlib/lib -L/usr/lib64  "-Wl,-rpath,/home/silencer/lrose-build/lib" -ldsdata -lMdv -lRadx -lSpdb -ldsserver -ldidss -lrapforma
ts -leuclid -ltoolsa -ldataport -ltdrp -lnetcdf_c++ -lnetcdf -lhdf5_hl_cpp -lhdf5_cpp -lhdf5_hl -lhdf5 -lz -ludunits2 -lbz2 -lexpat -lbz2 -lz -lm  

As you can see, it is searching for libraries in /home/silencer/lrose-build/lib, while printenv shows that RAP_INST_LIB_DIR=/home/silencer/lrose-build/lib

This folder contains the libraries compiled while following the instructions from README_NETCDF_BUILD.md

Do you know what might be happening? Please let me know if more information is needed.

Thank you! Rodrigo

rpelorosso commented 7 years ago

I finally fixed it by adding the reference to Ncxx in makefile with -lNcxx, as it was missing.