NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

[netcdfgroup] help compling c++ code with netcdf.

Hi,
  I'm new to netcdf. But I'm sure I installed netcdf4 correctly on my computer, 
as it passed all the test. However, when I'm trying to link my .o files, I 
received a chunk of errors such as:
 /usr/local/netcdf/netcdf-4.0/cxx/netcdf.cpp:172: undefined reference to 
`nc_def_var'
 /usr/local/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::sync()':
 /usr/local/netcdf/netcdf-4.0/cxx/netcdf.cpp:275: undefined reference to 
`nc_sync'

The command I used for linking is as below: (assuming .o files are ready)
#Specify the compiler
CC =  g++

#Specify the compiling flags
CFLAGS = -c -I/usr/local/include
#OFLAGS = -g -o
OFLAGS = -O3 -o 
LFLAGS = -L/usr/local/lib -lnetcdf_c++

OBJS =              \
global_fun.o

XOBJ = ncextra.o
#=============================================================================
# Executable: xhydstmtem
#=============================================================================
ncextra : $(OBJS) $(XOBJ)
        $(CC) $(OFLAGS) ncextra $(OBJS) $(XOBJ) $(LFLAGS)
#=============================================================================

  Can anyone help me with this? I appreciate it. 
  Jinyun

Ph.D student
Earth and Atmosphric Sciences Department
Ecosystems and Biogeochemical Dynamics Laboratory
Purdue University CIVIL 3250, 550 Stadium Mall Drive West Lafayette, IN, 
47907-2051
http://web.ics.purdue.edu/~tang16/

  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: