[netcdfgroup] Unable to compile netCDF4-C++

On RedHat 7, using yum, I installed netCDF4 C and C++ libraries:

$ ls /usr/lib64/*netcdf*
/usr/lib64/libnetcdf_c++.so        /usr/lib64/libnetcdf.so
/usr/lib64/libnetcdf_c++.so.4      /usr/lib64/libnetcdf.so.7
/usr/lib64/libnetcdf_c++.so.4.2.0  /usr/lib64/libnetcdf.so.7.2.0

$ ls /usr/include/*netcdf*
/usr/include/netcdfcpp.h  /usr/include/netcdf.hh
/usr/include/netcdf.h     /usr/include/netcdf_meta.h


I am trying to compile the code:

#include <iostream>
#include <netcdf>

using namespace std;
using namespace netCDF;

int main()
{
   return 0;
}


using:

g++ -o test test.cpp -I/usr/include -L/usr/lib64 -lnetcdf_c++4 -lnetcdf -lm

​but get the error:

​
fatal error: netcdf: No such file or directory
 #include <netcdf>
                  ^
compilation terminated.

​I tried using netcdf.h and netcdfcpp.h. This gives me the error:

​
error: ‘netCDF’ is not a namespace-name
 using namespace netCDF;
error: expected namespace-name before ‘;’ token
 using namespace netCDF;

​I'll appreciate any help in trying to get this working.

Thanks,
Namu​
  • 2018 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: