LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-12-2008, 02:52 PM   #1
ron7000
Member
 
Registered: Nov 2007
Location: CT
Posts: 248

Rep: Reputation: 26
compile error: undefined reference to std::basic_ostream


I am trying to compile a very simple example c++ program on my system which is itanium2 (IA-64).
The example program is provided by a imaging software company, along with their set of libraries.
The jist of it is I write my own code to do what I need and link it with their libraries so I can read/write their library format.

Step 1 is making sure I can compile and link one of their simple examples.
I can compile the example program via g++ -c
but when I try to link it I get the following errors.
I'm guessing they compiled their libraries with some sort of other standard library template that I don't have?
The provider of the libraries has compiled them on an ia-64 linux system using gcc versions 4.2.4 and 3.2.3. Initially I thought the problem was they had done it with 3.2.3 and I had 4.1.2, but now they've provided me the libraries made on either a Suse or Redhat system with gcc version 4.x but it still does not work for me.
What could I be missing? Any help would be greatly appreciated.

My system is an sgi altix 4700 running SuSE Linux Enterprise Server 10 sp1,
gcc (GCC) 4.1.2 20070115 (prerelease) (SUSE Linux)
LD_LIBRARY_PATH is : /opt/intel/fc/10.1.017/lib:/opt/intel/cc/10.1.017/lib:/usr/local/lib:/usr/local/share:/usr/local/lib:/usr/local/share
and I also have the intel c++ verson 10.1.017 but that gives the same errors.



g++ dumpsig.cpp -I../include -L../lib -ltdfio -ltdfio-netcdf -ltdfio-hdf -ltdfio-jpeg -ltdfio-zlib -lm

I've also tried the above with -lstdc++ at the end after -lm, and also with the -static option but still get the following thousand errors:

Code:
../lib/libtdfio.a(tdfbase.o): In function `TDF::dataTypeDescription(TDF::TdfDataType)':
tdfbase.cpp:(.text+0x3f2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfbase.cpp:(.text+0x422): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../lib/libtdfio.a(tdfenvironment.o): In function `TdfEnvironment::setAllTemperatures(float)':
tdfenvironment.cpp:(.text+0x1442): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x1472): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x14a2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)'
tdfenvironment.cpp:(.text+0x14d2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../lib/libtdfio.a(tdfenvironment.o): In function `TdfEnvironment::setAllOffsets(float)':
tdfenvironment.cpp:(.text+0x1662): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x1692): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x16c2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)'
tdfenvironment.cpp:(.text+0x16f2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../lib/libtdfio.a(tdfenvironment.o): In function `ConvertModelWeatherType(TdfEnvironment::TdfModelWeatherType&, AltitudeLocation&, bool, char const*)':
tdfenvironment.cpp:(.text+0x1b62): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x1b92): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x1bc2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x1c22): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../lib/libtdfio.a(tdfenvironment.o):tdfenvironment.cpp:(.text+0x1cf2): more undefined references to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)' follow
../lib/libtdfio.a(tdfenvironment.o): In function `TdfEnvironment::setTemperature(TdfEnvironment::TdfBoxFace, float)':
tdfenvironment.cpp:(.text+0x2e72): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)'
tdfenvironment.cpp:(.text+0x2ea2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../lib/libtdfio.a(tdfenvironment.o): In function `TdfEnvironment::setOffset(TdfEnvironment::TdfBoxFace, float)':
tdfenvironment.cpp:(.text+0x3082): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x30b2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
tdfenvironment.cpp:(.text+0x30e2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)'
tdfenvironment.cpp:(.text+0x3112): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../lib/libtdfio.a(tdfenvironment.o): In function `TdfEnvironment::setInternalData(EnvironmentData const&, TdfTerrainBase const&, FileNameData const&)':
tdfenvironment.cpp:(.text+0x33c2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
 
Old 09-12-2008, 04:01 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Have you the libstdc++ library installed? Which version?
 
Old 09-12-2008, 05:01 PM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I am not c++ expert, far from that
but isnt't it a typical namespace problem ?
declaring 'using namespace std;' wouldn't solve this ?
[edit]
More likely a missing package, as colucix suggest

Last edited by keefaz; 09-12-2008 at 05:05 PM.
 
Old 09-16-2008, 01:04 PM   #4
ron7000
Member
 
Registered: Nov 2007
Location: CT
Posts: 248

Original Poster
Rep: Reputation: 26
word back from the oem was that the problem was on their end when they compiled their library package under gcc 4.2.4.
I have gcc 4.1.2 and I think the c++ template libraries are incompatible.
They are in the process of making me a version under 4.1.2,
and I am in the process of building gcc 4.2.4.

also came across this article which i think describes some of the problem,
http://www.trilithium.com/johan/2005/06/static-libstdc/


how do i find out what version of libstdc++ I have?
It's whatever is installed automatically when you install SuSE linux enterprise server 10sp1.

Last edited by ron7000; 09-16-2008 at 01:06 PM.
 
Old 09-16-2008, 03:42 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by ron7000 View Post
how do i find out what version of libstdc++ I have?
Code:
rpm -qa | grep libstdc++
 
Old 09-17-2008, 09:13 AM   #6
ron7000
Member
 
Registered: Nov 2007
Location: CT
Posts: 248

Original Poster
Rep: Reputation: 26
thanks, I have

compat-libstdc++-x86-5.0.7-22.2
libstdc++-devel-4.1.2_20070115-0.15.6
compat-libstdc++-5.0.7-22.2
libstdc++-doc-4.1.2_20070115-0.15.6
libstdc++-x86-4.1.2_20070115-0.15.6
libstdc++-4.1.2_20070115-0.15.6



found, or fixed, my problem.
The software vendor compiled their libraries with gcc 4.2.4, and I have 4.1.2 installed which is what comes with Suse 10. The problem is 4.2.4 is not compatible with 4.1.2, which is what that article suggests.

I always have trouble when trying to build gcc, but this time I got lucky.
Was able to build gcc 4.2.4 and install it into /usr/local/gcc4.2.4.

to compile my example program using g++ version 4.1.2 on my system, all I have to do in addition to what I was doing (which was all correct) is -L/usr/local/gcc-4.2.4/lib. this is so the linker can find the correct versions of the stdc++ and libgcc libraries that the 3rd party libraries were compiled under. It links with zero errors now.

but, when I go to run the executable I get an the error:
/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by dumpsig.x)

that's because it's looking at the version 4.1.2 shared libraries. The fix for this is
appending /usr/local/gcc-4.2.4/lib to the LD_LIBRARY_PATH environment variable.
Then the executable works.

lesson i learned is don't assume the boundaries of compatibility are limited to the major version number of gcc (i.e. gcc 4.x.x is all compatible). You really need to have the same major and minor numbers: 4.2.x.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gtkboard compile error: undefined reference to `FT_GlyphSlot_Embolden' rextor Linux - Games 2 11-18-2011 05:24 PM
undefined reference to `g_assertion_message_expr when trying to compile jpilot nowshining Linux - Software 1 04-28-2008 11:37 PM
Compile QT get Undefined reference jordban Linux - General 14 01-15-2005 06:58 PM
2.6-test9 compile problem - undefined reference to `ide_hwifs' saint Linux - General 5 11-20-2003 04:53 PM
ncurses compile error: "undefined reference" Mr. Eek Linux From Scratch 1 05-12-2003 04:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration