473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem linking netcdf - Undefined References...

Hi - since my Suse 10.1 didn't have netcdf support enabled by default,
I downloaded the sources from
http://www.unidata.ucar.edu/software/netcdf/ then did
../configure --prefix=/usr
make
make test --succeeded
make extra_test --succeeded
make install

In my /usr/include I now have the files
netcdfcpp.h
netcdf.h
netcdf.hh

and in /usr/lib I have
libnetcdf.a
libnetcdf_c++.a

And while now my program using netcdf compiles fine, the linker will
complain about undefined references - I tried compiling with
g++ -o test test.cpp
g++ -o test test.cpp -lnetcdf
g++ -o test test.cpp -lnetcdf_c++
g++ -o test test.cpp -lnetcdf -lnetcdf_c++
and with
g++ -o test test.cpp /usr/lib/libnetcdf.a
g++ -o test test.cpp /usr/lib/libnetcdf_c++.a
g++ -o test test.cpp /usr/lib/libnetcdf.a /usr/lib/libnetcdf_c++.a
also
g++ -o test -I/usr/include -L/usr/lib test.cpp

All of them fail :(

Program test.cpp:
--------------------
#include <netcdf.hh>

using namespace std;

int main( int argc, char ** argv )
{
NcFile file("out.txt", NcFile::Replace);
return 0;
}
------------------------

Anyone able to help?

Regards,

Lars

Aug 18 '06 #1
5 3510

<la**********@rwth-aachen.dewrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi - since my Suse 10.1 didn't have netcdf support enabled by default,
I downloaded the sources from
http://www.unidata.ucar.edu/software/netcdf/ then did
./configure --prefix=/usr
make
make test --succeeded
make extra_test --succeeded
make install

In my /usr/include I now have the files
netcdfcpp.h
netcdf.h
netcdf.hh

and in /usr/lib I have
libnetcdf.a
libnetcdf_c++.a

And while now my program using netcdf compiles fine, the linker will
complain about undefined references - I tried compiling with
g++ -o test test.cpp
g++ -o test test.cpp -lnetcdf
g++ -o test test.cpp -lnetcdf_c++
g++ -o test test.cpp -lnetcdf -lnetcdf_c++
and with
g++ -o test test.cpp /usr/lib/libnetcdf.a
g++ -o test test.cpp /usr/lib/libnetcdf_c++.a
g++ -o test test.cpp /usr/lib/libnetcdf.a /usr/lib/libnetcdf_c++.a
also
g++ -o test -I/usr/include -L/usr/lib test.cpp

All of them fail :(

Program test.cpp:
--------------------
#include <netcdf.hh>

using namespace std;

int main( int argc, char ** argv )
{
NcFile file("out.txt", NcFile::Replace);
return 0;
}
------------------------

Anyone able to help?
For problems with someone's library, you need to contact the people who
created or are supporting that library. For linker problems, you need to
contact the compiler vendor or ask in a newsgroup dedicated to that
compiler, or perhaps even the OS. There's nothing here related to the C++
language, which is what we discuss here.

-Howard


Aug 18 '06 #2
Howard wrote:
Anyone able to help?
For problems with someone's library, you need to contact the people who
created or are supporting that library. For linker problems, you need to
contact the compiler vendor or ask in a newsgroup dedicated to that
compiler, or perhaps even the OS. There's nothing here related to the C++
language, which is what we discuss here.
For just stating that, you didn't need to include a full quote...

Since there is no netcdf newsgroup, and this seems to be a general
library inclusion problem with the gnu compiler, I was hoping someone
here knows the problem and would be able to direct me to a solution.
And I still hope that. Telling me I am off-topic when there is no 100%
on-topic newsgroup didn't really help.

Regards,

Lars

Aug 18 '06 #3

<la**********@rwth-aachen.dewrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Howard wrote:
Anyone able to help?
For problems with someone's library, you need to contact the people who
created or are supporting that library. For linker problems, you need to
contact the compiler vendor or ask in a newsgroup dedicated to that
compiler, or perhaps even the OS. There's nothing here related to the
C++
language, which is what we discuss here.

For just stating that, you didn't need to include a full quote...

Since there is no netcdf newsgroup, and this seems to be a general
library inclusion problem with the gnu compiler, I was hoping someone
here knows the problem and would be able to direct me to a solution.
And I still hope that. Telling me I am off-topic when there is no 100%
on-topic newsgroup didn't really help.
You could try a newsgroup with "gnu" in the name.

Aug 18 '06 #4
"Howard" <al*****@hotmail.comschrieb:
You could try a newsgroup with "gnu" in the name.
That was more helpful, thanks, didn't think of that.

Regards,

Lars
Aug 18 '06 #5
<la**********@rwth-aachen.dewrote:
And while now my program using netcdf compiles fine, the linker will
complain about undefined references - I tried compiling with
[...]
g++ -o test test.cpp -lnetcdf -lnetcdf_c++
Just for the record, the problem was in the order of supplying the
libraries-to-link on the command line.
The correct order is
g++ -o test test.cpp -lnetcdf_c++ -lnetcdf

Reason:
http://webpages.charter.net/ppluzhnikov/linker.html
This works fine and solved the problem, thanks to
gnu.g++.help :)
Regards,

Lars
Aug 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joonas Paalasmaa | last post by:
Hi, When compiling Sketch's streamfilter C extension the errors below are raised during linking. What could cause the errors? (Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98) Here are...
5
by: bandw | last post by:
I am having a problem using Numeric-24.0b2 in conjunction with the NetCDF module from ScientificPython (version 2.4.9). This problem does not surface using Numeric-23.8. The problem arises in...
1
by: Brian J. Ackermann | last post by:
Hi everybody, I'm new to c++, and I'm working on this simple little application, which ought to compile just fine, but I'm missing something. The program has 4 file, 2 headers, and 2 cpp files....
7
by: Anton Ishmurzin | last post by:
Greetings All, I think everybodyknows the answer already. But i am quite a newbie in c++. I've got the following line in my code: ifstream ini_file_in("filename.dat", ios::in); But, the...
3
by: Marcin Balcerzak | last post by:
Hi, after some googling I've found the post, in which there was a recipe how to convert C to NASM. I'd copied and compiled remnum.c and wrote Makefile like: x.asm: x.bin ndisasm -u x.bin |...
0
by: Fei Liu | last post by:
Yet another problem to deal with dynamic data type that can only be determined at run time. For a netCDF file (a scientific data format), a variable is defined with its associating dimensions, i.e....
10
by: Markus Svilans | last post by:
Hi, I have a weird problem in a virtual method. The original method code raises an access violation when it is run. The solution to the problem is to declare a dummy integer inside the virtual...
2
by: kalyani1031 | last post by:
hi, Iam calling CPP function in C , I get the following undefined references. ./mycppinc/libmycppinc.a(cpp_file.o)(.text+0xd): In function `std::__verify_grouping(char const*, unsigned int,...
3
by: kalyani1031 | last post by:
hi, my problem is linking my cli module with XORP modules. I am calling my cli_main() in the XORP router manager module rtrmgr. It takes the files and compiles the files that are in the router...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.