ubuntu - GCC对HDF5的 undefined reference

标签 ubuntu gcc compiler-errors linker undefined-reference

编译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/

相关文章:

c++ - 尝试运行指针排序算法时出现段错误(核心已转储)

c - gcc 将临时变量定义为函数参数

java - java中的下溢异常错误

compiler-errors - 使用ARKit时Xcode9代码签名错误

linux - "crontab -e"和 "/etc/crontab"相同吗?

bash - 如何将php(及其stderr)中的exec调用的输出重定向到调用程序?

php - 为什么 php-mongodb 扩展无法工作?

c - 如何使用 GCC 获取与程序集输出内联的源代码行?

c - 使用 gcc,我无法获得第 3 方库 Cairo 来链接/编译

c# - 更改 ASP.NET MVC 项目命名空间后出现编译错误?