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.
Hello, It looks like you probably aren't linking against the C++ interface for netCDF. This is separate from the core C library, libnetcdf. The good news is that it appears the C++ library, libnetcdf-cxx4. Try linking your library against libnetcdf-cxx4 in addition to libnetcdf, and see if the issue is resolved. If not, let me know! Have a great day, -Ward > Hi, > > I am quite new to Netcdf and trying to use it for my code. I have > installed netcdf4 and c++, here the logs for nc-config —all > > nc-config --all > > This netCDF 4.6.1 has been built with the following features: > > --cc -> gcc > --cflags -> -I/usr/local/include -I/usr/local/include > --libs -> -L/usr/local/lib -lnetcdf > > --has-c++ -> no > --cxx -> > > --has-c++4 -> yes > --cxx4 -> g++ > --cxx4flags -> -I/usr/local/include > --cxx4libs -> -L/usr/local/lib -lnetcdf_c++4 -lnetcdf > > --has-fortran-> no > --has-dap -> no > --has-dap4 -> no > --has-nc2 -> yes > --has-nc4 -> yes > --has-hdf5 -> yes > --has-hdf4 -> no > --has-logging-> no > --has-pnetcdf-> no > --has-szlib -> no > --has-parallel -> no > --has-cdf5 -> yes > > --prefix -> /usr/local > --includedir-> /usr/local/include > --libdir -> /usr/local/lib > --version -> netCDF 4.6.1 > > I am getting following errors while using it in a code (some of the > errors I am copying here): > > error: undefined reference to > 'netCDF::NcFile::NcFile(std::__cxx11::basic_string<char, > std::char_traits<char>, std::allocator<char> > const&, > netCDF::NcFile::FileMode)' > > error: undefined reference to > 'netCDF::NcGroup::getVar(std::__cxx11::basic_string<char, > > std::char_traits<char>, std::allocator<char> > const&, > netCDF::NcGroup::Location) const' > > error: undefined reference to 'netCDF::NcVar::getVar(double*) const’ > > > Also, I saw that after installing the netcdf, the netcdf file change to > a different symbol, but for my case its not. Please help me in this > regard. > > Thanks in advance. > > Regards > > Pawan > > > > Ticket Details =================== Ticket ID: WPL-663670 Department: Support netCDF Priority: Normal Status: Closed =================== NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.