> Thank-you Russ. Your suggestion to use libnetcdf_c++ works. > > I wish that I could use the newer netCDF C++ library (version 4.2?). > But my government manager and another programmer here are seriously > afraid that doing that will break that other programmer's code. So I'm > stuck with the older version. I had enough trouble getting the manager > to allow me to use C++! You can actually install both the old and new C++ libraries in the same directory without any name conflicts. But using a different API than your coworkers might interfere with collaborations :-). > By the way, what are the ".la" files in the "lib" directory? The .la file is used by libtool. Here's a better explanation than I could provide: http://stackoverflow.com/questions/1238035/what-is-libtools-la-file-for --Russ > On 6/2/2014 12:28 PM, Unidata netCDF Support wrote: > > Hi Bill, > > > >> //I'm having trouble linking my C++ test program with the //netCDF C++ > >> version 4.1.3 library. I do not have the option of using version 4.2. > >> The program compiles cleanly. Here's the source:/ > >> > >> #include <iostream> > >> #include <string> > >> > >> #include "/mgt/dev/apps/common/netcdf4/include/netcdfcpp.h" > >> > >> int main ( int argc , const char ** argv ) > >> > >> { > >> > >> std::cout << "\nPlease enter the name of the netCDF file " > >> << "that you want me to *try* to read." > >> << std::endl; > >> std::cout << ':'; > >> > >> std::string filename; > >> std::cin >> filename; > >> > >> std::cout << "\nThe filename you entered is:\n\"" > >> << filename > >> << "\".\n" > >> << std::endl; > >> > >> NcFile testfile ( filename.c_str () ); > >> > >> if (testfile.is_valid () == 0) > >> { > >> std::cout << "Version 4.1.3 of the netCDF C++ library " > >> << "cannot handle this file.\n" > >> << std::endl; > >> return 0; > >> } > >> > >> return 0; > >> > >> } > >> > >> /Here's what I get when I t//ry to build:/ > >> > >> address@hidden netcdf413]$ g++ -o main main.C > >> -L/mgt/dev/apps/common/netcdf4/lib/ -lnetcdf_c++4 > > The problem is using the wrong library. Your program calls the > > netCDF C++ "legacy" library API, but you are trying to link with > > a non-compatible newer version of the netCDF-4 C++ library. If > > you built successfully from netcdf-4.1.3, you should have > > installed libnetcdf_c++ files in the lib/ directory your linking > > with, in which case you can just use "-lnetcdf_c++" instead of > > "-lnetcdf_c++4" for linking your program. > > > > In case you want to use it, the newer netcdf-4 C++ library is > > available and explained in the Readme documentation appearing > > at the bottom of this web page: > > > > https://github.com/Unidata/netcdf-cxx4 > > > > but it's not upward compatible with the legacy API. > > > > --Russ > > > >> /tmp/ccwzCfrW.o: In function `main': > >> main.C:(.text+0x127): undefined reference to `NcFile::NcFile(char > >> const*, NcFile::FileMode, unsigned long*, unsigned long, > >> NcFile::FileFormat)' > >> main.C:(.text+0x130): undefined reference to `NcFile::is_valid() const' > >> main.C:(.text+0x185): undefined reference to `NcFile::~NcFile()' > >> main.C:(.text+0x194): undefined reference to `NcFile::~NcFile()' > >> collect2: ld returned 1 exit status > >> address@hidden netcdf413]$ > >> > >> /What am I doing wrong? ....or what am I not doing that I should be > >> doing? I and two co-workers are s//tumped.// > >> // > >> //Thank-you in advance for your help.// > >> //Bill./ > >> > >> -- > >> William (Bill) Mattison > >> NCWCP, cubicle 3693. > >> 301-683-3272. > >> > >> > >> > > Russ Rew UCAR Unidata Program > > address@hidden http://www.unidata.ucar.edu > > > > > > > > Ticket Details > > =================== > > Ticket ID: UHO-898473 > > Department: Support netCDF > > Priority: Normal > > Status: Closed > > > > -- > William (Bill) Mattison > NCWCP, cubicle 3693. > 301-683-3272. > > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: UHO-898473 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.