This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi, From the output you sent, the "make check" worked fine, and also compiled and ran the Fortran90 examples OK. But after running "make check", you also have to run "make install" to install the libraries and include files in directories where the compilers like ifort will be able to find them. "make install" will copy the necessary library and include files to subdirectories of /usr/local. You may have to run "make install" with superuser permissions, either as root or using the "sudo" command. After "make install" has run successfully, you can compile and link a Fortran program. > It shows in terminal like this : > yue@yue-p6515cn:~$ ifort '/home/yue/try.f90' -lnetcdf > > /tmp/ifortKEbUgd.o: In function `MAIN__': > > /home/yue/try.f90:(.text+0x48): undefined reference to > `netcdf_mp_nf90_inq_libvers_' You need to give the ifort compiler the necessary flags for where to find the netcdf.mod file and where to find the static library libnetcdf.a. These are what "nc-config --fflags" and "nc-config --flibs" show: > --fflags -> -g -I/usr/local/include > > --flibs -> -L/usr/local/lib -lnetcdf -lhdf5_hl -lhdf5 -lz -lm > -L/usr/lib/i386-linux-gnu -lcurl -Wl,-Bsymbolic-functions So you can compile try.f90 to produce try.o like this: ifort -g -I/usr/local/include -c try.f90 Then you can link try.o with the netCDF library like this to produce the executable program named try: ifort try.o -o try -L/usr/local/lib -lnetcdf -lhdf5_hl -lhdf5 -lz -lm -L/usr/lib/i386-linux-gnu -lcurl -Wl,-Bsymbolic-functions Or, you can use nc-config output on the ifort command line instead, to specify the ifort arguments to compile and then link like this: ifort `nc-config --fflags` -c try.f90 ifort try.o -o try `nc-config --flibs` Or you can do both the compile and link steps in one ifort command, like this: ifort `nc-config --fflags` try.f90 -o try `nc-config --flibs` > I have been working on it for weeks , and I can't solve it . I hope the above helps. You are using netCDF 4.1.1, which produces static libraries by default. If you decide to upgrade to netCDF 4.1.3, it produces shared libraries by default, but also separates the C and Fortran libraries into two separate libraries, which simplifies the link arguments. It also creates an "nf-config" command for Fortran that replaces the "nc-config" command above. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: OYI-144949 Department: Support netCDF Priority: Normal Status: Closed