0

When linking my hdf5 code I get the following error. Any ideas what I have done wrong.

The command I am using:

g++ -std=c++11 -m64 -DOPENFOAM_PLUS=1712 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -I/opt/software/OpenFOAM/OpenFOAM-v1712/src/finiteVolume/lnInclude -I/opt/software/OpenFOAM/OpenFOAM-v1712/src/sampling/lnInclude -I/opt/software/OpenFOAM/OpenFOAM-v1712/src/meshTools/lnInclude -IlnInclude -I. -I/opt/software/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude -I/opt/software/OpenFOAM/OpenFOAM-v1712/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPInt32Opt/3DIBicoFoam_2.o -L/opt/software/OpenFOAM/OpenFOAM-v1712/platforms/linux64GccDPInt32Opt/lib \ -lfiniteVolume -lsampling -L/local/hulfeldl/hdf5/lib/libhdf5_hl_cpp.a -L/local/hulfeldl/hdf5/lib/libhdf5_cpp.a -L/local/hulfeldl/hdf5/lib/libhdf5_hl.a -L/local/hulfeldl/hdf5/lib/libhdf5.a -lhdf5_hl_cpp -lhdf5_cpp -lhdf5_hl -lhdf5 -lsz -lz -ldl -lm -lOpenFOAM -ldl \ -lm -o /local/hulfeldl/OpenFOAM/hulfeldl-v1712/applications/bin/linux64GccDPInt32Opt/3DIBicoFoam_2

Error:

Make/linux64GccDPInt32Opt/3DIBicoFoam_2.o: In function `main':
3DIBicoFoam_2.C:(.text.startup+0x107b): undefined reference to 
`H5::H5Location::openDataSet(std::string const&) const' 
3DIBicoFoam_2.C:(.text.startup+0x17de): undefined reference to 
`H5::H5Location::openDataSet(std::string const&) const'
3DIBicoFoam_2.C:(.text.startup+0x189e): undefined reference to 
`H5::H5Location::openDataSet(std::string const&) const'
3DIBicoFoam_2.C:(.text.startup+0x1919): undefined reference to 
`H5::H5Location::openDataSet(std::string const&) const'
3DIBicoFoam_2.C:(.text.startup+0x19d0): undefined reference to 
`H5::H5Location::openDataSet(std::string const&) const'
Avishek Bhattacharya
  • 6,534
  • 3
  • 34
  • 53
L.H
  • 33
  • 2
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – wally Apr 26 '18 at 12:21
  • How did you generate that command? It's a gynormous mess. `-L/local/hulfeldl/hdf5/lib/libhdf5.a` is meaning less. `-L` adds library search directories. Please remove all `-L/...a` to start with. Add one single `-L/local/hulfeldl/hdf5/lib` leave all -lhdf... in the command. And retry. – Kaveh Vahedipour Apr 26 '18 at 12:32
  • Thanks. Now it's compiling. But when I execute I get: error while loading shared libraries: libhdf5_hl_cpp.so.100: cannot open shared object file: No such file or directory – L.H Apr 26 '18 at 12:51
  • if it is a C library, compiler will add parameters to function signature. May be extern "C" would resolve that problem – iyasar Apr 26 '18 at 13:43

1 Answers1

0

Please remove all -L/...a to start with. Add one single -L/local/hulfeldl/hdf5/lib leave all -lhdf... in the command. And retry.

For runtime please run the following before you run your program.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/local/hulfeldl/hdf5/lib
Kaveh Vahedipour
  • 3,412
  • 1
  • 14
  • 22