gfortran nc.f90 -I/mnt/f/longbow/Build_WRF/LIBRARIES/netcdf/include -L/mnt/f/longbow/Build_WRF/LIBRARIES/netcdf/lib -lnetcdf -o nc.exe >& 1.out
出現(xiàn)的錯誤信息為:
/tmp/ccfo8EnJ.o: In function `MAIN__':
nc.f90:(.text+0x395): undefined reference to `nf_open_'
nc.f90:(.text+0x418): undefined reference to `nf_strerror_'
nc.f90:(.text+0x478): undefined reference to `nf_inq_'
nc.f90:(.text+0x4e2): undefined reference to `nf_strerror_'
nc.f90:(.text+0x59e): undefined reference to `nf_inq_dim_'
nc.f90:(.text+0x608): undefined reference to `nf_strerror_'
nc.f90:(.text+0x73b): undefined reference to `nf_inq_var_'
nc.f90:(.text+0x7a9): undefined reference to `nf_strerror_'
nc.f90:(.text+0x956): undefined reference to `nf_inq_attname_'
nc.f90:(.text+0x9c0): undefined reference to `nf_strerror_'
nc.f90:(.text+0xa9f): undefined reference to `nf_inq_atttype_'
nc.f90:(.text+0xb09): undefined reference to `nf_strerror_'
nc.f90:(.text+0xbe8): undefined reference to `nf_inq_atttype_'
nc.f90:(.text+0xc52): undefined reference to `nf_strerror_'
collect2: error: ld returned 1 exit status
問題解決了,查了半天資料灼捂,什么原因還是不了解课梳。最后成功的編譯方式如下:
gfortran -o nc.exe nc.f90 //mnt/f/longbow/Build_WRF/LIBRARIES/netcdf/lib/libnetcdff.a //mnt/f/longbow/Build_WRF/LIBRARIES/netcdf/lib/libnetcdf.a -I//mnt/f/longbow/Build_WRF/LIBRARIES/netcdf/include