Unix Programming - Forcing Older Library

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2006 > Forcing Older Library





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Forcing Older Library
Brian C

2006-10-20, 7:23 pm

Hello all,
I am compiling code on my Linux machine via g++. It is picking up
libstdc++.so.6 (I believe). My web host provider only has upto
libstd++.so.3 (2003 version, yes, it's old and they don't plan to
upgrade any time soon).

How could I (aside from renaming the libraries), force g++ to use the
..3 library on my machine so I don't have to compiler on theirs?

Thanks.
Paul Pluzhnikov

2006-10-21, 1:27 am

Brian C <brianc@no.sp.a.m.dynamissoftware.com> writes:

> I am compiling code on my Linux machine via g++. It is picking
> up libstdc++.so.6 (I believe). My web host provider only has
> upto libstd++.so.3 (2003 version, yes, it's old and they don't
> plan to upgrade any time soon).


AFAICT, libstdc++.so.3 shipped with gcc-3.0, which was released
in 2001.

If you think numbers 3 and 6 have anything to do with year of
release, you are mistaken.

> How could I (aside from renaming the libraries), force g++ to
> use the .3 library on my machine so I don't have to compiler
> on theirs?


You can't. The libraries have incompatible interface (that's *why*
the version was incremented).

If you must run with libstdc++.so.3, then you must build with an
older version of gcc (3.0 -- I believe that neither 3.1 nor 3.2
will do).

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Brian C

2006-10-21, 1:27 am

Paul Pluzhnikov wrote:
> Brian C <brianc@no.sp.a.m.dynamissoftware.com> writes:
>
>
> AFAICT, libstdc++.so.3 shipped with gcc-3.0, which was released
> in 2001.
>
> If you think numbers 3 and 6 have anything to do with year of
> release, you are mistaken.

Oh no, I didn't think that. I got the dates from "g++ --version".
Basically, they are running g++ (GCC) 3.2.3 20030502 (Red Hat Linux
3.2.3-56). I'm running g++ (GCC) 4.1.0 20060304.

>
> You can't. The libraries have incompatible interface (that's *why*
> the version was incremented).
>
> If you must run with libstdc++.so.3, then you must build with an
> older version of gcc (3.0 -- I believe that neither 3.1 nor 3.2
> will do).


Kind of figured that, but it was definitely worth a shot! =)
Paul Pluzhnikov

2006-10-21, 1:27 am

Brian C <brianc@no.sp.a.m.dynamissoftware.com> writes:

> Oh no, I didn't think that. I got the dates from "g++
> --version". Basically, they are running g++ (GCC) 3.2.3 20030502 (Red
> Hat Linux 3.2.3-56). I'm running g++ (GCC) 4.1.0 20060304.


There is no way gcc-3.2.3 is using libstdc++.so.3:

$ /usr/local/gcc-3.2/bin/g++ junk.c && ldd a.out
libstdc++.so.5 => /usr/local/gcc-3.2/lib/libstdc++.so.5 (0x3ff7c000)
....
[vbcol=seagreen]

If it's the libstdc++.so.5 you are really after, then use gcc
versions 3.2 and 3.3 (3.4 changed the interface again, and uses
libstdc++.so.6).

Note that you don't have to "downgrade" your installed compiler --
just configure and install gcc-3.3 with different --prefix.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Brian C

2006-10-22, 1:20 am

Paul Pluzhnikov wrote:
> Brian C <brianc@no.sp.a.m.dynamissoftware.com> writes:
>
>
> There is no way gcc-3.2.3 is using libstdc++.so.3:
>
> $ /usr/local/gcc-3.2/bin/g++ junk.c && ldd a.out
> libstdc++.so.5 => /usr/local/gcc-3.2/lib/libstdc++.so.5 (0x3ff7c000)
> ...
>

You're right. I just a did a ldd on the file compiled on their machine
and it is .5. I'm not sure where I came up with that! =)


> If it's the libstdc++.so.5 you are really after, then use gcc
> versions 3.2 and 3.3 (3.4 changed the interface again, and uses
> libstdc++.so.6).
>
> Note that you don't have to "downgrade" your installed compiler --
> just configure and install gcc-3.3 with different --prefix.


I'll look into that, thanks!
Paul Pluzhnikov

2006-10-22, 1:20 am

Brian C <brianc@no.sp.a.m.dynamissoftware.com> writes:

>
> I'll look into that, thanks!


Actually, there is even simpler option:

Link your executable (using your installed g++-4.1.0) like this:

g++ -o cgi-whatever main.o ... -Wl,-rpath='$ORIGIN/../lib'

Then upload your cgi-whatever into its regular place
(e.g. /path/to/cgi-bin/ ) *and* upload your libstdc++.so.6 into
/path/to/lib.

Your executable will then use your own "private" copy of
libstdc++.so.6, and from that point you don't care what happens
with the "system" g++ install.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Brian C

2006-10-22, 7:20 am

Paul Pluzhnikov wrote:
> Brian C <brianc@no.sp.a.m.dynamissoftware.com> writes:
>
>
> Actually, there is even simpler option:
>
> Link your executable (using your installed g++-4.1.0) like this:
>
> g++ -o cgi-whatever main.o ... -Wl,-rpath='$ORIGIN/../lib'
>
> Then upload your cgi-whatever into its regular place
> (e.g. /path/to/cgi-bin/ ) *and* upload your libstdc++.so.6 into
> /path/to/lib.
>
> Your executable will then use your own "private" copy of
> libstdc++.so.6, and from that point you don't care what happens
> with the "system" g++ install.
>
> Cheers,

Wow, nice! I didn't even think of that. I already paid for the SSH
access for a year (dont mind, was cheap), I just didn't want to keep my
source on their servers, or keep uploading it, etc, etc .. thanks again!
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com