【问题标题】:GCC undefined reference to HDF5GCC 未定义对 HDF5 的引用
【发布时间】:2018-05-07 12:54:33
【问题描述】:

在编译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 的相对缺乏经验,我无法遵循所提供的解决方案。

你能给我解决这个问题的想法吗?

【问题讨论】:

    标签: ubuntu gcc compiler-errors linker undefined-reference


    【解决方案1】:

    您没有链接到 HDF5 库。

    静态库(就像netcdf 库一样)只不过是目标文件的存档,它实际上与在命令行中指定目标文件本身没有什么不同。因此,静态库的所有依赖项必须在链接时指定。

    还要记住顺序很重要。如果库 A 依赖于库 B,那么在命令行中 A 必须位于 B 之前。

    【讨论】:

      猜你喜欢
      • 2017-10-26
      • 1970-01-01
      • 1970-01-01
      • 2019-08-10
      • 2015-08-23
      • 1970-01-01
      • 2014-04-21
      • 2012-12-12
      • 2019-05-05
      相关资源
      最近更新 更多