compile error: undefined reference to std::basic_ostream
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.