Re: [netcdfgroup] Unable to compile netCDF4-C++

Thanks. Without installing libnetcdf_c++4 I did manage to compile and
execute my code using the command:

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


The order was key in getting it working here.

I wanted to install netCDF for C++ from the tarball but needed to install
gcc version 5 or greater, and thus, went for the easy route of using yum.

Namu

On Wed, Jul 18, 2018 at 6:27 PM Gus Correa <gus@xxxxxxxxxxxxxxxxx> wrote:

> Hi Namu
>
> For the record, I am not a C++ programmer.
> This is all I can do to help.
>
> On CentOS 7.5, with the same libraries as you,
> I get the same errors.
> It looks like libnetcdf_c++ is the legacy/obsolete version.
> 'yum info' shows this:
>
> Description : Legacy netCDF C++ library.  This library is provided
>                for backward
>              : compatibility only. New C++ development should
>                be done with the netCDF
>              : CXX4 C++ library.
>
> See also this:
>
> https://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg12530.html
>
> But unfortunately that is the one available in Red Hat/CentOS 7.
>
> The new interface is libnetcdf_c++4.
> You point to it in your compilation command, but you don't have that
> library installed.
>
> Unfortunately I couldn't find the libnetcdf_c++4 for RedHat/CentOS 7
> on epel, which is too bad.
>
> However, on Fedora Core 26, with libnetcdf.so.11.0.4 and
> libnetcdf_c++4.so.1.0.3 the program compiles fine.
>
> So, I guess this problem is really a matter of having only
> the obsolete libnetcdf_c++ library.
>
> I hope this helps,
> Gus Correa
>
> On 07/18/2018 04:34 PM, namu patel wrote:
> > 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​
> >
> >
> >
> > _______________________________________________
> > NOTE: All exchanges posted to Unidata maintained email lists are
> > recorded in the Unidata inquiry tracking system and made publicly
> > available through the web.  Users who post to any of the lists we
> > maintain are reminded to remove any personal information that they
> > do not want to be made public.
> >
> >
> > netcdfgroup mailing list
> > netcdfgroup@xxxxxxxxxxxxxxxx
> > For list information or to unsubscribe,  visit:
> http://www.unidata.ucar.edu/mailing_lists/
> >
>
> _______________________________________________
> NOTE: All exchanges posted to Unidata maintained email lists are
> recorded in the Unidata inquiry tracking system and made publicly
> available through the web.  Users who post to any of the lists we
> maintain are reminded to remove any personal information that they
> do not want to be made public.
>
>
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe,  visit:
> http://www.unidata.ucar.edu/mailing_lists/
  • 2018 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: