This is the mail archive of the
mailing list for the libstdc++ project.
RE: How do I select a version of libstdc+ to link against?
- From: David Aldrich <David dot Aldrich at EMEA dot NEC dot COM>
- To: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, Paolo Carlini <paolo dot carlini at oracle dot com>
- Date: Thu, 22 Sep 2011 10:46:43 +0000
- Subject: RE: How do I select a version of libstdc+ to link against?
- References: <41302A7145AC054FA7A96CFD03835A0A054FDB@EX10MBX02.EU.NEC.COM> <4E7A0F28.firstname.lastname@example.org>
> > Hi
> > I am running Ubuntu 10.04, which has g++ 4.4 installed by default. I want to
> > run g++ 4.1.3 so I installed 4.1.3 and set is as the default using update-
> > alternatives. However, I suspect that although I am compiling with 4.1.3, I am
> > actually linking to libstdc+ 4.4.
> > Note that your issues have very little to do with the *development* of
> > libstdc++. Actually, I would say have little to do also with the *use*
> > of GCC as GCC, these are generic Unix / Linux questions, thus I'm not even
> > sure about recommending gcc-help instead.
> > How can I determine which version of libstdc+ I am linking against?
> > ldd on the executable, for example.
> > How can I select which version of libstdc+ to link against?
> LD_LIBRARY_PATH, for example.
Hi Paolo and Jonathan
Thanks for your replies. I am sorry that my post was inappropriate for this list, but if I explain my problem further I think you will find some relevance.
Our C++ application uses the boolalpha manipulator with an istringstream object to read Boolean values from a string into a vector of strings. The code runs fine when compiled with g++ 4.1.2 on Centos 5.3, but another user reported that it failed when compiled with g++ 4.1.3 on Ubuntu 10.04. I think that the failure is related to:
gcc Bug 37958 - 'num_get<>::do_get(bool) sets eofbit flag incorrectly when boolalpha == true'
As far as I can see, this bug resulted in a change to libstdc++ 4.4. If the Ubuntu case is using that library, that could explain the failure.
I can either ensure that the older version of libstdc++ is used, or I can modify the code so that it complies with the new behaviour of boolalpha. The latter is preferable, as one day we should move to 4.4, so I would like to ask for some help to make the code change please.
Here is my test case:
cout << "start of test" << endl;
std::istringstream iss("true true");
while ( !iss.eof() )
if ( !iss.fail() )
cout << "fail" << endl;
cout << myVect.size() << endl;
cout << "end of test" << endl;
Output on g++ 4.1.2 (Centos 5.3):
start of test
end of test
Output on g++ 4.1.3 (Ubuntu 10.04):
start of test
end of test
This means that the 4.1.3 case traversed the while loop 3 times. That is, eof() was not true after reading the second Boolean. I really don't understand the discussion in the bug report but, for some reason, this behaviour seems to be what was required.
I can fix the error but changing the while condition to:
while ( iss.tellg() < iss.str().size() )
This seems a bit messy. Is there a better way?