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 dear, > Yesterday, I have sent an email to describle problem of applying the > netcdf API in f90 code (download from > http://www.unidata.ucar.edu/software/netcdf/examples/programs/) . > I have tried the examples of fortran 77 and C (*mple_xy_wr.c* and > simple_xy_wr.f<http://www.unidata.ucar.edu/software/netcdf/examples/programs/simple_xy_wr.f>) > from above webstie, and the same problems occurred. > For > simple_xy_wr.f<http://www.unidata.ucar.edu/software/netcdf/examples/programs/simple_xy_wr.f>: > :~/Research/fortran$ gfortran simple_xy_wr.f > /tmp/ccSNpe9z.o: In function `MAIN__': > simple_xy_wr.f:(.text+0xf0): undefined reference to `nf_create_' > simple_xy_wr.f:(.text+0x13e): undefined reference to `nf_def_dim_' > simple_xy_wr.f:(.text+0x18c): undefined reference to `nf_def_dim_' > simple_xy_wr.f:(.text+0x204): undefined reference to `nf_def_var_' > simple_xy_wr.f:(.text+0x230): undefined reference to `nf_enddef_' > simple_xy_wr.f:(.text+0x270): undefined reference to `nf_put_var_int_' > simple_xy_wr.f:(.text+0x29c): undefined reference to `nf_close_' > /tmp/ccSNpe9z.o: In function `handle_err_': > simple_xy_wr.f:(.text+0x3bd): undefined reference to `nf_strerror_' > collect2: ld return 1 > For *mple_xy_wr.c* : > ~/Research/fortran$ gcc simple_xy_wr.c > /tmp/cc68GDtY.o: In function `main': > simple_xy_wr.c:(.text+0x7b): undefined reference to `nc_create' > simple_xy_wr.c:(.text+0x8f): undefined reference to `nc_strerror' > simple_xy_wr.c:(.text+0xcd): undefined reference to `nc_def_dim' > simple_xy_wr.c:(.text+0xe1): undefined reference to `nc_strerror' > simple_xy_wr.c:(.text+0x11f): undefined reference to `nc_def_dim' > simple_xy_wr.c:(.text+0x133): undefined reference to `nc_strerror' > simple_xy_wr.c:(.text+0x18c): undefined reference to `nc_def_var' > simple_xy_wr.c:(.text+0x1a0): undefined reference to `nc_strerror' > simple_xy_wr.c:(.text+0x1c7): undefined reference to `nc_enddef' > simple_xy_wr.c:(.text+0x1db): undefined reference to `nc_strerror' > simple_xy_wr.c:(.text+0x213): undefined reference to `nc_put_var_int' > simple_xy_wr.c:(.text+0x227): undefined reference to `nc_strerror' > simple_xy_wr.c:(.text+0x24e): undefined reference to `nc_close' > simple_xy_wr.c:(.text+0x262): undefined reference to `nc_strerror' > collect2: ld return 1 > So please help me! Thank you! > > --------------------------------------------------- > Xianghui XUE > > Howdy Xianghui XUE! You must link to the netCDF library when building netCDF programs, and use the appropriate -I and -L options. It is described here: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c/Compiling.html#Compiling Good luck! Ed Ticket Details =================== Ticket ID: XYB-168481 Department: Support netCDF Priority: High Status: Closed