NSF Unidata

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

[netCDF #MEU-519242]: How to configure Xcode, C++, netCDF together.

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.



Hi Wenfang,

I'm not familiar with using the Xcode tools on Mac OS X either,
so I'm not sure how to add your netCDF installed library.  The
Xcode linker will have to find both libraries libnetcdf_c++.a
and libnetcdf.a, and presumably you have both of those installed
in /usr/local/lib.  It's typically not enough to just identify
the library with -L/usr/local/lib, you also have to specify which
libraries, with something like

  g++ ... -L/usr/local/lib -lnetcdf_c++ -lnetcdf ...

and I don't see those libraries mentioned on your g++ invocation.

The following command line should work, so if you can get XCode to
generate something similar, it should solve the problem:

  g++ -I/usr/local/include simple_xy_wr.cpp -o simple_xy_wr \
      -L/usr/local/lib -lnetcdf_c++ -lnetcdf

--Russ

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: MEU-519242
Department: Support netCDF
Priority: Normal
Status: Closed