编译IOAPI-3.1时,遇到此错误:
cd /home/usr/ioapi/Linux2_x86_64gfort; gfortran /home/usr/ioapi/Linux2_x86_64gfort/airs2m3.o -L/home/usr/ioapi/Linux2_x86_64gfort -lioapi -lnetcdff -lnetcdf -fopenmp -dynamic -L/usr/lib64 -lm -lpthread -lc -o airs2m3
/usr/bin/ld: /home/usr/ioapi/Linux2_x86_64gfort/libnetcdf.a(libnetcdf4_la-nc4file.o): undefined reference to symbol 'H5DSget_num_scales@@HDF5_SERIAL_1.8.7'
/usr/lib/mpich/lib/libhdf5_serial_hl.so.100: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:181: recipe for target 'airs2m3' failed
make[1]: *** [airs2m3] Error 1
make[1]: Leaving directory '/home/usr/ioapi/m3tools'
Makefile:141: recipe for target 'all' failed
make: *** [all] Error 2
我已经阅读了与我的问题Strange linking error: DSO missing from command line有关的帖子,但是由于我对Linux的相对经验不足,所以我无法遵循提出的解决方案。
您能给我一些解决办法吗?
最佳答案
您没有链接到HDF5库。
静态库(就像netcdf
库一样)只不过是目标文件的存档,实际上与在命令行上指定目标文件本身没有什么不同。因此,链接时必须指定静态库的所有依赖项。
还请记住,顺序很重要。如果库A依赖于库B,则在命令行上A必须在B之前。
关于ubuntu - GCC对HDF5的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47457503/