I need to work with the NetCDF Format in C++ (I use Visual Studio as an IDE) and the C++ interface seems to be problematic, so I want to use the C Library as it is avaiable as a prebuilt library:
https://www.unidata.ucar.edu/software/netcdf/docs/winbin.html
I used the NetCDF-4 32-bit Version. Now I have my .nc files saved in some folder and want to open these with the method ncopen as below:
#include<netcdf.h>
#include<string>
#include<iostream>
using namespace std;
int main() {
const char* pathPointer = "foo";
int ncid;
int status;
status = nc_open(pathPointer, NC_NOWRITE, &ncid);
return 0;
}
But now, I get the following errors:
LNK2019 unresolved external symbol _nc_open referenced in function _main NetCDFtest C:\Users\Marcel\Documents\Visual Studio 2019\Projects\NetCDFtest\NetCDFtest\Quelle.obj 1
LNK1120 1 unresolved externals NetCDFtest C:\Users\Marcel\Documents\Visual Studio 2019\Projects\NetCDFtest\Debug\NetCDFtest.exe 1
I think that I linked everything properly, I tried it as in the answer of the following post:
Visual Studio - adding netCDF library
So, I do not know what the problem could be. As it is a C library, I tried to use extern "C" {} around the include part as below:
#extern "C" {
#include<netcdf.h>
}
However, I get the same errors as above. Does anyone have an idea?