2013-12-20 38 views
0

我想构建一个使用NetCDF库的f90程序。对象的汇编很顺利。但在连接阶段,这与创建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。任何人都知道什么是错的,或者我应该如何着手解决这个问题?

+0

你有'hdf5.mod'硬盘上的某个地方? –

+0

不,它不在/ usr,/ opt或/ Applications/Xcode下,所以我认为我没有它 – Patrick

+0

我认为拥有'hdf5.mod'文件是必要的,但我不使用NetCDF,所以我不是最有资格回答的人。 –

回答

2

NetCDF4和HDF5都配备了辅助程序

  • NF-配置
  • NC-配置
  • h5fc
  • h5cc

他们有没有得到安装?我会默认使用它们,为你的情况:

gfortran-mp-4.7 -g -O2 -Wall -o myProg myObj1.o myObj2.o `nf-config --fflags --flibs` 
+0

就这么简单! – Patrick