Solved

Cannot compile simple C++ Netcdf program using linked libraries in non-standard directory

Posted on 2008-10-03
7
2,155 Views
Last Modified: 2013-11-13
Hi,

I'm trying to compile a simple Netcdf test case, as I do not have root access to my machine I've installed the libraries on my workspace /home/s0091681/netcdf2/include and /home/s0091681/netcdf2/lib (I'm using a university Linux system).  When I try to compile I get errors complaining about 'undefined reference' (see snippet)  after a quick Google, it looks like others have had the same problem and it is to do with the order that libraries are linked.

I've used the following in bash:

g++ -I/home/s0091681/netcdf2/include/  -L/home/s0091681/netcdf2/lib -lnetcdf_c++ -lnetcdf -o test simple_xy_wr.cpp

and tried various permutations of the parameters, in different orders etc.

This really shouldn't be as difficult as I'm finding it.  Am I doing something really stupid?

Many thanks

Niall


bash-3.2$ g++ -I/home/s0091681/netcdf2/include/  -L/home/s0091681/netcdf2/lib -lnetcdf_c++ -lnetcdf -o test simple_xy_wr.cpp 

/tmp/ccwL7zue.o: In function `main':

simple_xy_wr.cpp:(.text+0xf2): undefined reference to `NcFile::NcFile(char const*, NcFile::FileMode, unsigned long*, unsigned long, NcFile::FileFormat)'

simple_xy_wr.cpp:(.text+0xfb): undefined reference to `NcFile::is_valid() const'

simple_xy_wr.cpp:(.text+0x135): undefined reference to `NcFile::add_dim(char const*, long)'

simple_xy_wr.cpp:(.text+0x14c): undefined reference to `NcFile::add_dim(char const*, long)'

simple_xy_wr.cpp:(.text+0x185): undefined reference to `NcFile::add_var(char const*, NcType, NcDim const*, NcDim const*, NcDim const*, NcDim const*, NcDim const*)'

simple_xy_wr.cpp:(.text+0x1b7): undefined reference to `NcVar::put(int const*, long, long, long, long, long)'

simple_xy_wr.cpp:(.text+0x1f6): undefined reference to `NcFile::~NcFile()'

simple_xy_wr.cpp:(.text+0x212): undefined reference to `NcFile::~NcFile()'

collect2: ld returned 1 exit status

Open in new window

0
Comment
Question by:duncan54747
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
libin_v earned 500 total points
ID: 22633057
g++ -I/home/s0091681/netcdf2/include/  -o test simple_xy_wr.cpp -L/home/s0091681/netcdf2/lib -lnetcdf_c++ -lnetcdf

You should always provide the librarys at the end. Please refer http://www.network-theory.co.uk/docs/gccintro/gccintro_18.html
0
 

Author Comment

by:duncan54747
ID: 22633330
Hi I tried your suggestion, but still no luck.

bash-3.2$ g++ -I/home/s0091681/netcdf2/include/ -o test simple_xy_wr.cpp -L/home/s0091681/netcdf2/lib-lnetcdf-lnetcdf_c++

/tmp/ccYFa4BG.o: In function `main':
simple_xy_wr.cpp:(.text+0xf2): undefined reference to `NcFile::NcFile(char const*, NcFile::FileMode, unsigned long*, unsigned long, NcFile::FileFormat)'
simple_xy_wr.cpp:(.text+0xfb): undefined reference to `NcFile::is_valid() const'
simple_xy_wr.cpp:(.text+0x135): undefined reference to `NcFile::add_dim(char const*, long)'
simple_xy_wr.cpp:(.text+0x14c): undefined reference to `NcFile::add_dim(char const*, long)'
simple_xy_wr.cpp:(.text+0x185): undefined reference to `NcFile::add_var(char const*, NcType, NcDim const*, NcDim const*, NcDim const*, NcDim const*, NcDim const*)'
simple_xy_wr.cpp:(.text+0x1b7): undefined reference to `NcVar::put(int const*, long, long, long, long, long)'
simple_xy_wr.cpp:(.text+0x1f6): undefined reference to `NcFile::~NcFile()'
simple_xy_wr.cpp:(.text+0x212): undefined reference to `NcFile::~NcFile()'
collect2: ld returned 1 exit status
0
 
LVL 5

Expert Comment

by:libin_v
ID: 22633418
There is no space between the libraries in the command you mentioned

bash-3.2$ g++ -I/home/s0091681/netcdf2/include/ -o test simple_xy_wr.cpp -L/home/s0091681/netcdf2/lib    -lnetcdf   -lnetcdf_c++
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:duncan54747
ID: 22633533
Hi,

Sorry just realised.  Tried again without spaces.  Produces significantly more error messages now.  Perhaps I'm missing something else, compiler not up-to-date?
bash-3.2$ g++ -I/home/s0091681/netcdf2/include/ -o test simple_xy_wr.cpp -L/home/s0091681/netcdf2/lib -lnetcdf -lnetcdf_c++

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcError::set_err(int)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1648: undefined reference to `nc_strerror'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcAtt::values() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1584: undefined reference to `nc_get_att_schar'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1566: undefined reference to `nc_get_att_double'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1560: undefined reference to `nc_get_att_float'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1572: undefined reference to `nc_get_att_int'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1578: undefined reference to `nc_get_att_short'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1590: undefined reference to `nc_get_att_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcAtt::is_valid() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1548: undefined reference to `nc_inq_attid'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcAtt::num_vals() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1537: undefined reference to `nc_inq_attlen'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcAtt::type() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1528: undefined reference to `nc_inq_atttype'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::sync()':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1432: undefined reference to `nc_inq_varname'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::num_dims() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:622: undefined reference to `nc_inq_varndims'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::type() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:608: undefined reference to `nc_inq_vartype'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcDim':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:517: undefined reference to `nc_def_dim'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:517: undefined reference to `nc_def_dim'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:503: undefined reference to `nc_inq_dimname'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:503: undefined reference to `nc_inq_dimname'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcDim::sync()':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:488: undefined reference to `nc_inq_dimname'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcDim::is_unlimited() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:456: undefined reference to `nc_inq_unlimdim'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcDim::size() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:440: undefined reference to `nc_inq_dimlen'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::data_mode()':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:344: undefined reference to `nc_enddef'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(double*, long const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1255: undefined reference to `nc_get_vara_double'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(float*, long const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1254: undefined reference to `nc_get_vara_float'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(long*, long const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1253: undefined reference to `nc_get_vara_long'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(int*, long const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1252: undefined reference to `nc_get_vara_int'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(short*, long const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1251: undefined reference to `nc_get_vara_short'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(char*, long const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1248: undefined reference to `nc_get_vara_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(signed char*, long const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1238: undefined reference to `nc_get_vara_schar'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(double*, long, long, long, long, long) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1216: undefined reference to `nc_get_vara_double'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(float*, long, long, long, long, long) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1215: undefined reference to `nc_get_vara_float'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(long*, long, long, long, long, long) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1214: undefined reference to `nc_get_vara_long'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(int*, long, long, long, long, long) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1213: undefined reference to `nc_get_vara_int'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(short*, long, long, long, long, long) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1212: undefined reference to `nc_get_vara_short'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(char*, long, long, long, long, long) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1209: undefined reference to `nc_get_vara_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get(signed char*, long, long, long, long, long) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1178: undefined reference to `nc_get_vara_schar'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(double const*, long const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1116: undefined reference to `nc_put_vara_double'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(float const*, long const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1115: undefined reference to `nc_put_vara_float'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(long const*, long const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1114: undefined reference to `nc_put_vara_long'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(int const*, long const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1113: undefined reference to `nc_put_vara_int'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(short const*, long const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1112: undefined reference to `nc_put_vara_short'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(char const*, long const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1109: undefined reference to `nc_put_vara_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(signed char const*, long const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1096: undefined reference to `nc_put_vara_schar'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(double const*, long, long, long, long, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1070: undefined reference to `nc_put_vara_double'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(float const*, long, long, long, long, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1069: undefined reference to `nc_put_vara_float'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(long const*, long, long, long, long, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1068: undefined reference to `nc_put_vara_long'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(int const*, long, long, long, long, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1067: undefined reference to `nc_put_vara_int'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(short const*, long, long, long, long, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1066: undefined reference to `nc_put_vara_short'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(char const*, long, long, long, long, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1063: undefined reference to `nc_put_vara_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::put(signed char const*, long, long, long, long, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1031: undefined reference to `nc_put_vara_schar'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::define_mode()':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:330: undefined reference to `nc_redef'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcAtt::remove()':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1621: undefined reference to `nc_del_att'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcAtt::rename(char const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1612: undefined reference to `nc_rename_att'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::rename(char const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1406: undefined reference to `nc_rename_var'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, int, double const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1396: undefined reference to `nc_put_att_double'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, int, float const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1395: undefined reference to `nc_put_att_float'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, int, long const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1394: undefined reference to `nc_put_att_long'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, int, int const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1393: undefined reference to `nc_put_att_int'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, int, short const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1392: undefined reference to `nc_put_att_short'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, int, char const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1384: undefined reference to `nc_put_att_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, int, signed char const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1372: undefined reference to `nc_put_att_schar'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, char const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1349: undefined reference to `nc_put_att_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, float)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1339: undefined reference to `nc_put_att_float'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, double)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1332: undefined reference to `nc_put_att_double'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1331: undefined reference to `nc_put_att_long'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, int)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1330: undefined reference to `nc_put_att_int'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, short)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1329: undefined reference to `nc_put_att_short'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, char)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1323: undefined reference to `nc_put_att_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::add_att(char const*, signed char)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1313: undefined reference to `nc_put_att_schar'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcDim::rename(char const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:468: undefined reference to `nc_rename_dim'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::abort()':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:321: undefined reference to `nc_abort'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::get_format() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:256: undefined reference to `nc_inq_format'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::set_fill(NcFile::FillMode)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:237: undefined reference to `nc_set_fill'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::num_atts() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:61: undefined reference to `nc_inq_natts'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::num_atts() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:656: undefined reference to `nc_inq_varnatts'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::attname(int) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1482: undefined reference to `nc_inq_attname'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::attnum(char const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1470: undefined reference to `nc_inq_attname'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::num_vars() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:51: undefined reference to `nc_inq_nvars'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::get_var(char const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:78: undefined reference to `nc_inq_varid'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::num_dims() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:41: undefined reference to `nc_inq_ndims'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::close()':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:314: undefined reference to `nc_close'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get_dim(int) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:631: undefined reference to `nc_inq_var'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::values() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:728: undefined reference to `nc_get_vara_schar'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:710: undefined reference to `nc_get_vara_double'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:704: undefined reference to `nc_get_vara_float'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:716: undefined reference to `nc_get_vara_int'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:722: undefined reference to `nc_get_vara_short'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:734: undefined reference to `nc_get_vara_text'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar::get_rec(NcDim*, long)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:841: undefined reference to `nc_get_vara_schar'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:847: undefined reference to `nc_get_vara_text'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:835: undefined reference to `nc_get_vara_short'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:829: undefined reference to `nc_get_vara_int'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:817: undefined reference to `nc_get_vara_float'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:823: undefined reference to `nc_get_vara_double'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::rec_dim() const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:114: undefined reference to `nc_inq_unlimdim'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::get_dim(char const*) const':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:68: undefined reference to `nc_inq_dimid'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1451: undefined reference to `nc_inq_varname'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:400: undefined reference to `nc__create'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:384: undefined reference to `nc__open'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:400: undefined reference to `nc__create'

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:384: undefined reference to `nc__open'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::sync()':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:275: undefined reference to `nc_sync'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::add_var(char const*, NcType, int, NcDim const**)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:194: undefined reference to `nc_def_var'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcFile::add_var(char const*, NcType, NcDim const*, NcDim const*, NcDim const*, NcDim const*, NcDim const*)':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:172: undefined reference to `nc_def_var'

/home/s0091681/netcdf2/lib/libnetcdf_c++.a(netcdf.o): In function `NcVar':

/tmp/n4_yakov/netcdf-4.0/cxx/netcdf.cpp:1451: undefined reference to `nc_inq_varname'

collect2: ld returned 1 exit status

Open in new window

0
 
LVL 5

Expert Comment

by:libin_v
ID: 22633803
trying adding these also to the library list -lhdf5_hl -lhdf5 -lz

ie
g++ -I/home/s0091681/netcdf2/include/ -o test simple_xy_wr.cpp -L/home/s0091681/netcdf2/lib    -lnetcdf   -lnetcdf_c++   -lhdf5_hl -lhdf5 -lz
0
 
LVL 5

Expert Comment

by:libin_v
ID: 22633863
sorry could u try this

bash-3.2$ g++ -I/home/s0091681/netcdf2/include/ -o test simple_xy_wr.cpp -L/home/s0091681/netcdf2/lib  -lnetcdf_c++   -lnetcdf

reverse the order of libraries
0
 

Author Comment

by:duncan54747
ID: 22634316
Hi, I've installed the previous netCDF distribution so 3.63 instead of 4.  Got it working now.  I guess 4 had a dependence on something not installed on my machine.

Works with the first command you suggested so I'll accept that as solution.

Thanks very much for the help!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now