I am using PGI Visual Fortran in (Windows OS) to build a project/solution consisting of a fortran (f90) library and an executable. The f90 library links to the netcdf.lib. The f90 compiles and builds OK, but when I try to link it to the executable I get the following errors:
Compiling Project ...
Linking... error LNK2019: unresolved external symbol nf_ _inq_varid_ referenced in function interpnwptools_checkcldliq_ error LNK2001: unresolved external symbol nf__inq varid error LNK2019: unresolved external symbol nf_ strerror_ referenced in function error error LNK2019: unresolved external symbol nf_ get_ att_ real_ referenced in function error LNK2001: unresolved external symbol nf_ get_ att_ real_ error LNK2019: u开发者_如何学Pythonnresolved external symbol nf_ create_ referenced in function ncdf_module_openfile_ error LNK2019: unresolved external symbol nf_def_dim_ referenced in function ncdf_module_openfile_ . . . and a whole other bunch of nf_ unresolved symbols. I don't think that the netcdf library is getting linked properly. Can anyone help? The project that I am using requires netcdf 3.6.0-p1, which I built myself using MS VStudio 2003. I've also tried to build the project using gfortran and eclipse, but have the same linking problem. I've never used netcdf or fortran before... Any suggestions?Your suspicion is correct - the NetCDF library is not getting linked properly. Assuming it was properly built, you'll need to tell Visual Fortran where to look to find the library. I don't do any PGI-VF work, but it looks like you can edit the property pages for your project. Look for setting options for the Linker, and you should be able to add directories that the linker will search for the requisite libraries. You may also need to specify the NetCDF libraries themselves as additional dependencies in the Linker Input options.
I suspect the problem is that Fortran libraries built with/for different compilers use different calling conventions (name mangling, argument passing, etc.) and are therefore incompatible with each other (in most cases). Try to see if you have the right download and compilation settings for your netcdf library.
精彩评论