Unidata / netcdf-cxx4

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

Undefined Reference to netCDF #93

Open matthew894 opened 4 years ago

matthew894 commented 4 years ago

To report a non-security related issue, please provide:

*NETcdf 4.3.1 c++

include

netCDF::NcFile dataFile("simple_xy.nc", netCDF::NcFile::replace);

program then crashes with the following

/home/matthew/CLionProjects/2DCodeVersion1.0/Diff_Water_Tensor_2D.cpp:14: undefined reference to netCDF::NcFile::NcFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, netCDF::NcFile::FileMode)' /home/matthew/CLionProjects/2DCodeVersion1.0/Diff_Water_Tensor_2D.cpp:14: undefined reference tonetCDF::NcFile::~NcFile()'

atharris commented 4 years ago

I get a very similar issue to this when building NetCDF-CXX4 into another C++ project:

I suspect this is an issue of things being compiled with different versions of GCC or against different C++ standards, but I haven't been able to resolve it on my end. I've tried adjusting the cmake to force compilation against C++ by changing line 430 in the CMakeLists.txt file to: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wno-unused-variable -Wno-unused-parameter -std=c++11") which seemed to work (i.e., still passed all tests and installed successfully) but it has not resolved my issue.