首先,我读过这个主题,但我无法编译我的代码。Compiling Fortran netCDF programs on Ubuntu
我正在Ubuntu14.04上编译一个使用NetCDF的fortran程序。我有这样的编译错误:
terrain.f:(.text+0x17efd): undefined reference to 'ncopn_'
terrain.f:(.text+0x18111): undefined reference to 'ncopn_'
terrain.f:(.text+0x187cc): undefined reference to 'ncclos_'
terrain.f:(.text+0x187ea): undefined reference to 'ncclos_'当然,上面写着我还没有福特兰图书馆。但是我根据这些网页安装了zlib、HDF5、netcdf和netcdf,并提供了禁用、共享和禁用dap选项。
default.html http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-fortran-install.html
这是libs命令的结果:
-L/usr/local/lib -L/usr/local -lnetcdf -lhdf5_hl -lhdf5 -ldl -lm -lz这是nf-config -flibs命令的结果:
-L/usr/local/lib -lnetcdff -L/usr/local/lib -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lz我使用以下命令构建我的项目:
gfortran terrain.f -I/usr/local/include -L/usr/local/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz -lm -ldl这是怎么回事?
编辑:我在配置netcdf和netcdf时使用--禁用-netcdf-4选项,我可以编译我的代码。所以这是HDF5的一个问题。
发布于 2015-04-24 02:24:02
这并不是一个真正的答案,但你需要产生更多的信息。编写一个简单的程序,给我们看代码。然后向我们展示用于尝试和编译的命令。
以下是两个例子:
Fortran 77:
$ cat test_nc.f
PROGRAM TEST_NC
IMPLICIT NONE
include 'netcdf.inc'
INTEGER ncid, nc_err
nc_err = nf_open('test.nc', nf_nowrite, ncid)
nc_err = nf_close(ncid)
END PROGRAM TEST_NC
$ gfortran test_nc.f -o test_nc `nf-config --fflags --flibs`Fortran 90:
$ cat test_nc.f90
program test_nc
use netcdf
implicit none
integer :: ncid, nc_err
nc_err = nf90_open('test.nc', nf90_nowrite, ncid)
nc_err = nf90_close(ncid)
end program test_nc
$ gfortran test_nc.f90 -o test_nc `nf-config --fflags --flibs`这两种方法都在我的系统上编译,没有错误,甚至没有警告。
https://stackoverflow.com/questions/29813922
复制相似问题