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.
> Institution: CATIE > Package Version: 3.6.1 > Operating System: Windows XP > Hardware Information: PC > Inquiry: Hi, > > I've recently downloaded the netcdf binaries (version 3.6.1), in order to build an application to write netcdf data in the Windows XP platform. > I tried to build one of the c++ examples from the Unidata web page, but simply I can't make it work. > Under Visual C++ 6.0 and Visual C++.NET, both from the IDE and the command-line compiler, I get the following message: > > ----------------------------------------------------------------------------------------------------- > Compiling... > simple_xy_wr.cpp > Linking... > simple_xy_wr.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall NcVar::put(int const *,long,long,long,long,long)" (?put@NcVar@@QAEIPBHJJJJJ@Z) > simple_xy_wr.obj : error LNK2001: unresolved external symbol "public: class NcVar * __thiscall NcFile::add_var(char const *,enum NcType,class NcDim const *,class NcDim const *,class NcDim const *,class NcDim const *,class NcDim const *)" (?add_var@NcFil > e@@QAEPAVNcVar@@PBDW4NcType@@PBVNcDim@@2222@Z) > simple_xy_wr.obj : error LNK2001: unresolved external symbol "public: class NcDim * __thiscall NcFile::add_dim(char const *,long)" (?add_dim@NcFile@@QAEPAVNcDim@@PBDJ@Z) > simple_xy_wr.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall NcFile::~NcFile(void)" (??1NcFile@@UAE@XZ) > simple_xy_wr.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall NcFile::is_valid(void)const " (?is_valid@NcFile@@QBEIXZ) > simple_xy_wr.obj : error LNK2001: unresolved external symbol "public: __thiscall NcFile::NcFile(char const *,enum NcFile::FileMode,unsigned int *,unsigned int,enum NcFile::FileFormat)" (??0NcFile@@QAE@PBDW4FileMode@0@PAIIW4FileFormat@0@@Z) > Debug/simple_xy_wr.exe : fatal error LNK1120: 6 unresolved externals > Error executing link.exe. > simple_xy_wr.exe - 7 error(s), 0 warning(s) > ----------------------------------------------------------------------------------------------------- > > I included the static library (netcdf.lib) in the code but it's just the same. I figured out that the problem could be the static library, so I tried to build it, using the source code, but I had problems with the header file config.h, which is neither in my system nor in the source code provided. > > I found a reply from James Garnett explaining that command-line compiler could do, but I can't simply introduce the right options to the linker in order to fix this. I thought executing the linker as: "link /DEFAULTLIB:netcdf.lib simple_xy_wr.obj" would work, but it doesn't. > > Could you give me a hand? > Thanks very much > Best, > > Luis Molina > > > > Howdy Luis! The netCDF C++ API has never been ported to Visual Studio. The C API has been, and you may find the VS solution file in the win32/NET directory of the netCDF source distribution. The DLL contains the C API, and you may use that from C++, or you may port the C++ API (which should not be too hard for someone that knows visual studio well). Thanks, Ed Ticket Details =================== Ticket ID: ORG-563735 Department: Support netCDF Priority: Normal Status: Closed