[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #OCN-379575]: Error in compiling netcdf example code simple_xy-wr.cpp
- Subject: [netCDF #OCN-379575]: Error in compiling netcdf example code simple_xy-wr.cpp
- Date: Thu, 30 May 2013 09:47:41 -0600
Hi Abir,
> I have installed NetCDF C++ package on linux and I am using Netbeans
> IDE to write my own codes. I have added the /usr/local/include and
> usr/local/lib to the C++ compiler and the linker respectively in the
> project properties. When I am trying to compile the simple_xy_wr.cpp
> file, I am receiving the error "Undefined reference to NcFile" at anyline
> which uses this class or any of it's member functions. I tried to search
> this on the net but everyone said that I may be giving the wrong directory
> to the linker, but i have specifically added the lib directory in the
> project properties. I am unable to resolve this issue and kindly reply
> as soon as possible.
There are two different C++ libraries for netCDF, and the newer netCDF-4
API differs in incompatible ways from the older "legacy" C++ API for
netCDF-3. I suspect you are using the new netCDF-4 C++ API with the
documentation and examples for the legacy netCDF-3 C++ API.
Documentation for the new netCDF-4 C++ API is here:
http://www.unidata.ucar.edu/netcdf/docs/cxx4/
whereas the legacy netCDF-3 API is documented here:
http://www.unidata.ucar.edu/netcdf/docs/netcdf-cxx/
Both APIs have an NcFile class, but different methods:
http://www.unidata.ucar.edu/netcdf/docs/netcdf-cxx.html#Class-NcFile
http://www.unidata.ucar.edu/netcdf/docs/cxx4/classnetCDF_1_1NcFile.html
> Also, I would be glad if you could give me clear instructions for
> installing the NetCDF C++ package on linux with and without the NetCDF-4
> support. Please reply soon. I copied the compile log for your review
> below.
As far as building the legacy C++ library for netCDF-3, this worked for me,
after installing the netCDF-4 C library under /usr/local:
LD_LIBRARY_PATH=/usr/local/lib CPPFLAGS="-I/usr/local/include -DUSE_NETCDF4"
./configure --enable-netcdf-4
make check
sudo make install
--Russ
> /usr/bin/gmake -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
> gmake[1]: Entering directory `/home/local/test_Cpp'
> /usr/bin/gmake -f nbproject/Makefile-Debug.mk
> dist/Debug/GNU-Linux-x86/test_cpp
> gmake[2]: Entering directory `/home/local/test_Cpp'
> mkdir -p build/Debug/GNU-Linux-x86
> rm -f build/Debug/GNU-Linux-x86/main.o.d
> g++ -c -g -I../local/include -MMD -MP -MF
> build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o
> main.cpp
> mkdir -p dist/Debug/GNU-Linux-x86
> g++ -o dist/Debug/GNU-Linux-x86/test_cpp build/Debug/GNU-Linux-x86/main.o
> -L../local/lib -Wl,-rpath /home/local
> build/Debug/GNU-Linux-x86/main.o: In function `main':
> /home/local/test_Cpp/main.cpp:46: undefined reference to `NcFile::NcFile(char
> const*, NcFile::FileMode, unsigned long*, unsigned long, NcFile::FileFormat)'
> /home/local/test_Cpp/main.cpp:50: undefined reference to `NcFile::is_valid()
> const'
> /home/local/test_Cpp/main.cpp:63: undefined reference to
> `NcFile::add_dim(char const*, long)'
> /home/local/test_Cpp/main.cpp:64: undefined reference to
> `NcFile::add_dim(char const*, long)'
> /home/local/test_Cpp/main.cpp:68: undefined reference to
> `NcFile::add_var(char const*, NcType, NcDim const*, NcDim const*, NcDim
> const*, NcDim const*, NcDim const*)'
> /home/local/test_Cpp/main.cpp:73: undefined reference to `NcVar::put(int
> const*, long, long, long, long, long)'
> /home/local/test_Cpp/main.cpp:80: undefined reference to `NcFile::~NcFile()'
> /home/local/test_Cpp/main.cpp:80: undefined reference to `NcFile::~NcFile()'
> collect2: ld returned 1 exit status
> gmake[2]: *** [dist/Debug/GNU-Linux-x86/test_cpp] Error 1
> gmake[2]: Leaving directory
> `/home/MTS-AERO_Work-15/Aero_Design-15/Internship/TAU_Interpolation/test_Cpp'
> gmake[1]: *** [.build-conf] Error 2
> gmake[1]: Leaving directory
> `/home/MTS-AERO_Work-15/Aero_Design-15/Internship/TAU_Interpolation/test_Cpp'
> gmake: *** [.build-impl] Error 2
> The information in this e-mail is confidential. The contents may not be
> disclosed or used by anyone other than the addressee. Access to this e-mail
> by anyone else is unauthorised.
> If you are not the intended recipient, please notify Airbus immediately and
> delete this e-mail.
> Airbus cannot accept any responsibility for the accuracy or completeness of
> this e-mail as it has been sent over public networks. If you have any
> concerns over the content of this message or its Accuracy or Integrity,
> please contact Airbus immediately.
> All outgoing e-mails from Airbus are checked using regularly updated virus
> scanning software but you should take whatever measures you deem to be
> appropriate to ensure that this message and any attachments are virus free.
>
>
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: OCN-379575
Department: Support netCDF
Priority: Normal
Status: Closed