链接库引起的编译器错误(涉及HDF5库)

时间:2018-08-20 03:49:24

标签: cmake fortran shared-libraries gfortran hdf5

我正在使用Macbook上的CMake编译Fortran代码。使用的编译器是Gfortran。我的fortran代码使用HDF5库,该库是在Macbook上使用GNU编译的。

编译代码时,出现以下错误:

    [ 99%] Linking Fortran shared library libmycodelib.dylib
Undefined symbols for architecture x86_64:
  "___h5_dble_interface_MOD_h5aread_double_scalar", referenced from:
      ___hdf5_utils_m_MOD_read_attribute_real in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5awrite_double_scalar", referenced from:
      ___hdf5_utils_m_MOD_write_attribute_real in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5dread_double_1", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_real_rank1 in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5dread_double_2", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_real_rank2 in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5dread_double_3", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_real_rank3 in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5dread_double_scalar", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_real_rank0 in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5dwrite_double_1", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_real_rank1 in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5dwrite_double_2", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_real_rank2 in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5dwrite_double_3", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_real_rank3 in hdf5_utils.F90.o
  "___h5_dble_interface_MOD_h5dwrite_double_scalar", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_real_rank0 in hdf5_utils.F90.o
  "___h5a_provisional_MOD_h5aread_char_scalar", referenced from:
      ___hdf5_utils_m_MOD_read_attribute_string in hdf5_utils.F90.o
  "___h5a_provisional_MOD_h5aread_integer_scalar", referenced from:
      ___hdf5_utils_m_MOD_read_attribute_integer in hdf5_utils.F90.o
  "___h5a_provisional_MOD_h5awrite_char_scalar", referenced from:
      ___hdf5_utils_m_MOD_write_attribute_string in hdf5_utils.F90.o
  "___h5a_provisional_MOD_h5awrite_integer_scalar", referenced from:
      ___hdf5_utils_m_MOD_write_attribute_integer in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dread_char_1", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_string_rank1 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dread_integer_1", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_integer_rank1 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dread_integer_2", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_integer_rank2 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dread_integer_3", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_integer_rank3 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dread_integer_scalar", referenced from:
      ___hdf5_utils_m_MOD_read_dataset_integer_rank0 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dwrite_char_1", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_string_rank1 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dwrite_integer_1", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_integer_rank1 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dwrite_integer_2", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_integer_rank2 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dwrite_integer_3", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_integer_rank3 in hdf5_utils.F90.o
  "___h5d_provisional_MOD_h5dwrite_integer_scalar", referenced from:
      ___hdf5_utils_m_MOD_write_dataset_integer_rank0 in hdf5_utils.F90.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [libmycodelib.dylib] Error 1
make[1]: *** [CMakeFiles/mycodelib.dir/all] Error 2
make: *** [all] Error 2

似乎所有这些错误都与C-> Fortran数据类型有关。有人知道如何解决这些错误吗?

谢谢。

0 个答案:

没有答案