I am trying to build NetCDF4 from source on MacOSX. When I run ./configure I get the error:
我正在尝试从MacOSX上的源代码构建NetCDF4。当我运行。/configure我得到错误:
checking for library containing H5Fflush... no
configure: error: Can't find or link to the hdf5 library. Use --disable-netcdf-4, or see config.log for errors.
I installed hdf5 before, and set the environment variables as:
我之前安装了hdf5,并设置环境变量为:
LDFLAGS=-L/opt/local/lib
CPPFLAGS=-I/opt/local/include
In /opt/local/lib I have these files:
在/opt/local/lib中我有这些文件:
libhdf5.8.dylib
libhdf5.a
libhdf5.dylib
libhdf5.settings
libhdf5_cpp.8.dylib
libhdf5_cpp.a
libhdf5_cpp.dylib
libhdf5_hl.8.dylib
libhdf5_hl.a
libhdf5_hl.dylib
libhdf5_hl_cpp.8.dylib
libhdf5_hl_cpp.a
libhdf5_hl_cpp.dylib
And in /opt/local/include I have:
在/opt/local/包括:
hdf5.h hdf5_hl.h
Why doesn't the configure script find the hdf5 library? I am happy to provide more information if needed!
为什么配置脚本没有找到hdf5库?如果需要,我很乐意提供更多的信息!
EDIT: My ultimate goal is to install netcdf4 for use as a Fortran module. I have tried installing everything through MacPorts, and it seemed to work, but when I tried to use it, the compiler told me that there was no netcdf.mod file, and sure enough there wasn't one to be found anywhere. It turns out that just typing:
编辑:我的最终目标是安装netcdf4作为Fortran模块。我尝试过在MacPorts中安装所有的东西,它看起来很有用,但是当我尝试使用它时,编译器告诉我没有netcdf。mod文件,当然,在任何地方都找不到。结果是:
sudo port install netcdf-fortran
only installs the library files, but doesn't create a .mod file, which I guess is needed. So I found out that other people had the same problem, and the advice given was to install it with gcc44, which did create a .mod file, but then my compiler told me that the .mod file was built with a different version of gfortran and it couldn't be used, so that's why I am trying to build it from scratch, but if someone has a faster option, I would be more than happy to try it!
只安装库文件,但不创建.mod文件,我想这是需要的。所以我发现其他人有同样的问题,给出的建议是与gcc44安装它,并创建一个mod文件名,然后我的编译器告诉我,不同版本的mod文件名建于gfortran无法使用,这就是为什么我想从头开始构建它,但如果有人更快的选择,我将乐意试试!
2 个解决方案
#1
2
Ok, I finally figured it out. I reinstalled netcdf-fortran with macports, then the .mod file suddenly appeared, I then had the problem, however, that when running gfortran, it would tell me that netcdf.mod was compiled with a different version of fortran than the one I am using. (Macports uses 4.8), so got gcc48 from macports and am using gfortran-mp-4.8 to compile now and it works.
好吧,我终于明白了。我用macports重新安装了netcdf-fortran,然后这个.mod文件突然出现了,然后我遇到了问题,当运行gfortran时,它会告诉我netcdf。mod是用不同版本的fortran编译的,而不是我使用的版本。(Macports使用的是4.8),因此从Macports获得gcc48,现在正在使用gfortran-mp-4.8进行编译,它可以工作。
Still don't know how to build all these things from scratch, but it works now at least!!!
仍然不知道如何从头开始构建所有这些东西,但是至少现在是有效的!!!
#2
1
Typically, I see this when there is a downstream dependency that cannot be fulfilled. The test program created by configure
is finding libhdf5
, but compilation is still failing because it cannot find something like libz
or libszip
, depending on how your libhdf5 was compiled.
通常情况下,当存在无法实现的下游依赖时,我就会看到这种情况。通过configure创建的测试程序是找到libhdf5,但是编译仍然失败,因为它不能找到libzor或libszip之类的东西,这取决于您的libhdf5是如何编译的。
If you check your config.log
file and look for the error, it will probably tell you something along the lines of 'unresolved symbol'. This will give a clue as to which library is missing. If it is linking against the statically-built libhdf5, you may need to add the appropriate library usingLDFLAGS
.
如果你检查你的配置。日志文件并查找错误,它可能会告诉您一些“未解决的符号”。这将提供一个线索,关于哪个库丢失。如果它链接到静态构建的libhdf5,您可能需要添加适当的库usingLDFLAGS。
If you post the relevant portion of your config.log
file, we may be able to help sort out what exactly is going wrong.
如果您发布了配置的相关部分。日志文件,我们也许能够帮助找出到底出了什么问题。
#1
2
Ok, I finally figured it out. I reinstalled netcdf-fortran with macports, then the .mod file suddenly appeared, I then had the problem, however, that when running gfortran, it would tell me that netcdf.mod was compiled with a different version of fortran than the one I am using. (Macports uses 4.8), so got gcc48 from macports and am using gfortran-mp-4.8 to compile now and it works.
好吧,我终于明白了。我用macports重新安装了netcdf-fortran,然后这个.mod文件突然出现了,然后我遇到了问题,当运行gfortran时,它会告诉我netcdf。mod是用不同版本的fortran编译的,而不是我使用的版本。(Macports使用的是4.8),因此从Macports获得gcc48,现在正在使用gfortran-mp-4.8进行编译,它可以工作。
Still don't know how to build all these things from scratch, but it works now at least!!!
仍然不知道如何从头开始构建所有这些东西,但是至少现在是有效的!!!
#2
1
Typically, I see this when there is a downstream dependency that cannot be fulfilled. The test program created by configure
is finding libhdf5
, but compilation is still failing because it cannot find something like libz
or libszip
, depending on how your libhdf5 was compiled.
通常情况下,当存在无法实现的下游依赖时,我就会看到这种情况。通过configure创建的测试程序是找到libhdf5,但是编译仍然失败,因为它不能找到libzor或libszip之类的东西,这取决于您的libhdf5是如何编译的。
If you check your config.log
file and look for the error, it will probably tell you something along the lines of 'unresolved symbol'. This will give a clue as to which library is missing. If it is linking against the statically-built libhdf5, you may need to add the appropriate library usingLDFLAGS
.
如果你检查你的配置。日志文件并查找错误,它可能会告诉您一些“未解决的符号”。这将提供一个线索,关于哪个库丢失。如果它链接到静态构建的libhdf5,您可能需要添加适当的库usingLDFLAGS。
If you post the relevant portion of your config.log
file, we may be able to help sort out what exactly is going wrong.
如果您发布了配置的相关部分。日志文件,我们也许能够帮助找出到底出了什么问题。