Unidata / netcdf-cxx4

Official GitHub repository for netCDF-C++ libraries and utilities.
Other
124 stars 49 forks source link

undefined symbols on windows #47

Closed Weiming-Hu closed 7 years ago

Weiming-Hu commented 7 years ago

Hi there.

I have installed the pre-built binary netcdf-c library according to here. But when I go and build netcdf-cxx4 using CMake, I get the following errors.

CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x912): undefined reference to `nc_inq_att'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x9e9): undefined reference to `nc_get_att_double'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0xa7b): undefined reference to `nc_get_att_text'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0xbb9): undefined reference to `nc_open'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0xe00): undefined reference to `nc_inq_dimid'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x11f1): undefined reference to `nc_inq_varid'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x1348): undefined reference to `nc_close'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x17bc): undefined reference to `nc_open'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x17d7): undefined reference to `nc_inq_dimid'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x1806): undefined reference to `nc_inq_dimlen'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x1c42): undefined reference to `nc_open'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x1f75): undefined reference to `nc_inq_format'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x21c8): undefined reference to `nc_inq'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x22f7): undefined reference to `nc_inq_unlimdims'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x2418): undefined reference to `nc_inq_dim'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x266c): undefined reference to `nc_inq_varid'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x26af): undefined reference to `nc_inq_varnatts'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x2783): undefined reference to `nc_inq_attname'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x2b22): undefined reference to `nc_inq_var'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x2ce9): undefined reference to `nc_inq_dim'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x2eb2): undefined reference to `nc_inq_attname'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x32e1): undefined reference to `nc_inq_attname'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x3425): undefined reference to `nc_close'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x3a12): undefined reference to `nc_inq_varndims'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x3a7d): undefined reference to `nc_inq_var'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x3aee): undefined reference to `nc_inq_dimlen'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x3d98): undefined reference to `nc_open'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x3dc9): undefined reference to `nc_inq_varid'
CAnalogsIO/libCAnalogsIO.a(NcdfIO.cpp.obj):NcdfIO.cpp:(.text+0x3e5a): undefined reference to `nc_get_var_double'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [canalogs.exe] Error 1
make[1]: *** [CMakeFiles/canalogs.dir/all] Error 2
make: *** [all] Error 2

Any ideas? Thank you.

Weiming-Hu commented 7 years ago

Hi,

I have read more about the interface of netcdf on windows for netcdf-cxx4, and found this

Note: we don't have a C++ interface here

If this is still the case, I guess the interface has not been ported onto Windows yet, which caused the undefined reference errors.

WardF commented 7 years ago

Hi,

We should have an official windows installer supported release for the next version. You should be able to build it yourself currently using cmake to generate a visual studio project which can then be compiled into the C++ interface.

WardF commented 7 years ago

The errors you are getting are not related to the C++ library it appears; rather, whatever program it is you are trying to build is not linking against the C library (netcdf.dll). I infer this because the symbols that the linker is complaining about exist in the C library, not the C++ library.

Weiming-Hu commented 7 years ago

Got it. Thank you.