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

[netCDF #YBS-587954]: netCDF Support



Hello,

When you run g++, you need to link against the netCDF C++ library, otherwise 
the resultant executable does not know where to find the 'NcVar::' functions, 
as listed below.  Try the following:

    $ g++ -o readNet readNet.cpp -l netcdf-cxx4 -l netcdf

You may need to specify the location of your C++ and C libraries, if they are 
not in the standard locations on your system. 

I hope this helps!

-Ward

> Hello,
> 
> Im sorry this is a simple error but I can’t seem to fix it. I am having 
> trouble compiling and running the C++ example file found here.
> 
> https://www.unidata.ucar.edu/software/netcdf/examples/programs/SimpleXyWr.cpp
> 
> 
> 
> I have installed netcdf4 by using brew command ‘brew install netcdf’. I can 
> see it there under Celler along with the other dependancies I installed 
> (ncview etc..)
> 
> 
> 
> I have the c++ file inside of atom and named it ‘readNet.cpp’. When I run 
> this command from the terminal I get the following errors (sudo g++ -o 
> readNet readNet.cpp)
> 
> 
> Undefined symbols for architecture x86_64:
> "netCDF::NcVar::NcVar()", referenced from:
> _main in readNet-feb390.o
> "netCDF::NcVar::operator=(netCDF::NcVar const&)", referenced from:
> _main in readNet-feb390.o
> "netCDF::NcFile::NcFile(std::__1::basic_string<char, 
> std::__1::char_traits<char>, std::__1::allocator<char> > const&, 
> netCDF::NcFile::FileMode)", referenced from:
> _main in readNet-feb390.o
> "netCDF::NcFile::~NcFile()", referenced from:
> _main in readNet-feb390.o
> "netCDF::NcVar::getVar(float*) const", referenced from:
> _main in readNet-feb390.o
> "netCDF::NcVar::getVar(std::__1::vector<unsigned long, 
> std::__1::allocator<unsigned long> > const&, std::__1::vector<unsigned long, 
> std::__1::allocator<unsigned long> > const&, void*) const", referenced from:
> _main in readNet-feb390.o
> "netCDF::NcGroup::getVar(std::__1::basic_string<char, 
> std::__1::char_traits<char>, std::__1::allocator<char> > const&, 
> netCDF::NcGroup::Location) const", referenced from:
> _main in readNet-feb390.o
> "typeinfo for netCDF::exceptions::NcException", referenced from:
> GCC_except_table0 in readNet-feb390.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> 
> 
> 
> I have tried many things but I just cant seem to get it to compile. When I 
> remove the stuff inside the try and catch it runs (the blank program). Ive 
> also tried to get it running in xCode but when I link the dependancies it 
> comes up with cannot find netcdf. (#include <netcdf>).
> 
> Any help would be greatly appreciated
> 
> Thank you
> Sam
> 


Ticket Details
===================
Ticket ID: YBS-587954
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.