NSF Unidata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #KRJ-634869]: NetCDF C++ build error

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,

Sorry this reply hgas taken so long, we were at the AMS meeting all
last week.

In your Makefile, you have:

INC = /store/home/prabhakar/Desktop/netcdf/include
LIB = /store/home/prabhakar/Desktop/netcdf/lib -lnetcdf -lnetcdf_c++

ReadT2: ReadT2.o
        g++ -o ReadT2 ReadT2.o

ReadT2.o: ReadT2.cpp
        g++ -c -I$(INC) -L$(LIB) ReadT2.cpp

but you need the libraries specified on the link line instead of the
compiler line:


ReadT2: ReadT2.o
        g++ -o ReadT2 ReadT2.o -L$(LIB)

ReadT2.o: ReadT2.cpp
        g++ -c -I$(INC) ReadT2.cpp

Also, it would be more conventional to incorporate the "-L" into the
LIB macro definition instead, such as:

INC = -I/store/home/prabhakar/Desktop/netcdf/include
LIBS = -L/store/home/prabhakar/Desktop/netcdf/lib -lnetcdf -lnetcdf_c++

ReadT2: ReadT2.o
        g++ -o ReadT2 ReadT2.o $(LIBS)

ReadT2.o: ReadT2.cpp
        g++ -c $(INC) ReadT2.cpp

but that's just cosmetic, the other version should work as well.

--Russ



Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: KRJ-634869
Department: Support netCDF
Priority: Normal
Status: Closed