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 Nishant, I'll need a little more information; what version of the netCDF C++ interface are you using, and what version of the underlying netCDF-C library was it built against? Also, how are you trying to compile this program you included? It looks like perhaps you are not linking it properly against the C++ interface. -Ward > Full Name: Nishant Sharma > Email Address: address@hidden > Organization: San Jose State University > Package Version: > Operating System: > Hardware: > Description of problem: Hi, > I'm getting following error. Please let me know if you need any other details. > > Code > > #include <iostream> > #include <iomanip> > #include <netcdf> > > using namespace std; > using namespace netCDF; > using namespace netCDF::exceptions; > > > int main() > { > > NcFile > dataFile("/home/nishant/Documents/SJSU/CMPE275/Project/test/20140101_0000.gz",NcFile::read); > cout<<"there are "<<dataFile.getVarCount()<<" variables"<<endl; > > > } > > > > readfile.o: In function `main': > readfile.cpp:(.text+0x5a): undefined reference to > `netCDF::NcFile::NcFile(std::string const&, netCDF::NcFile::FileMode)' > readfile.cpp:(.text+0x83): undefined reference to > `netCDF::NcGroup::getVarCount(netCDF::NcGroup::Location) const' > readfile.cpp:(.text+0xc4): undefined reference to `netCDF::NcFile::~NcFile()' > readfile.cpp:(.text+0xeb): undefined reference to `netCDF::NcFile::~NcFile()' > readfile.cpp:(.text+0x116): undefined reference to `netCDF::NcFile::~NcFile()' > collect2: error: ld returned 1 exit status > > > Ticket Details =================== Ticket ID: XBB-605615 Department: Support netCDF Priority: Normal Status: Closed