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# - #在网络发布期间定义符号

java - 为什么这个 CircleTest 类不能编译

linux - Windows 7共享ubuntu目录但看不到里面的文件怎么办?

ruby-on-rails - Docker 镜像在 Ubuntu 16.04 上工作,但在 Ubuntu 18.04 上失败

linux - dotnet-install.sh 不在 Ubuntu 上添加 dotnet 命令

c++ - 错误 : expected unqualified-id before '||' token

c++ - 使用 makefile 编译 C++ 项目的问题

c++ - 原子读/写值的静态断言

apache - Docker 在子域上运行

c++ - 我可以将 C/C++ #defines 设为私有(private)吗?