gpt4 book ai didi

compiler-errors - 链接包括NetCDF代码的f90

转载 作者:行者123 更新时间:2023-12-02 10:51:52 27 4
gpt4 key购买 nike

我正在尝试构建一个使用NetCDF库的f90程序。对象的编译进展顺利。但是在与NetCDF库链接的链接阶段,存在一个问题:

gfortran-mp-4.7 -g -O2 -Wall -o myProg myObj1.o myObj2.o /opt/local/lib/libnetcdff.a /opt/local/lib/libnetcdf.a

Undefined symbols for architecture x86_64:
"_H5Aclose", referenced from:
_nc4_rec_read_vars in libnetcdf.a(libnetcdf4_la-nc4file.o)
_nc4_rec_read_vars_cb in libnetcdf.a(libnetcdf4_la-nc4file.o)
_nc4_rec_write_metadata in libnetcdf.a(libnetcdf4_la-nc4hdf.o)
_write_attlist in libnetcdf.a(libnetcdf4_la-nc4hdf.o)
_nc4_rec_write_types in libnetcdf.a(libnetcdf4_la-nc4hdf.o)
_write_netcdf4_dimid in libnetcdf.a(libnetcdf4_la-nc4hdf.o)
.
. [Similar paragraphs]
.
"_curl_easy_strerror", referenced from:
_ocfetchurl_file in libnetcdf.a(liboc_la-ochttp.o)
_ocfetchurl in libnetcdf.a(liboc_la-ochttp.o)
_ocfetchlastmodified in libnetcdf.a(liboc_la-ochttp.o)
_ocping in libnetcdf.a(liboc_la-ochttp.o)
"_curl_version_info", referenced from:
_oc_curl_protocols in libnetcdf.a(liboc_la-occurlfunctions.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

我不是一个非常有经验的程序员,但是我从中得到的显然是找不到 _H5Aclose之类的东西。 Google告诉我这属于 hdf5库。但是我似乎有这个:
pwd:/opt/local/include >> ls | grep hdf
hdf5.h
hdf5_hl.h

我也尝试将这些路径显式添加到链接器中(尽管未在makefile中指定)
gfortran-mp-4.7 -g -O2 -Wall -o myProg myObj1.o myObj2.o -L/opt/local/include -L/opt/local/lib /opt/local/lib/libnetcdff.a /opt/local/lib/libnetcdf.a

gfortran-mp-4.7 -g -O2 -Wall -o myProg myObj1.o myObj2.o -I/opt/local/include -I/opt/local/lib /opt/local/lib/libnetcdff.a /opt/local/lib/libnetcdf.a

但是我得到了同样的错误信息。我在Mac OS 10.8上,并且已经从macports安装了gcc(gfortran随附)和netcdf-fortran。有人知道这是怎么回事,或者我应该如何找出来?

最佳答案

NetCDF4和HDF5都带有辅助应用程序

  • nf-config
  • nc-config
  • h5fc
  • h5cc

  • 他们安装好了吗?在您的情况下,我会默认使用它们:
    gfortran-mp-4.7 -g -O2 -Wall -o myProg myObj1.o myObj2.o `nf-config --fflags --flibs`

    关于compiler-errors - 链接包括NetCDF代码的f90,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20709103/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com