Re: Linking the correct libstdc++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks very much Brian, my code now works.

I had to remove quite a lot of programmes that I was linking in and
recompile them all using gcc 3.3. Now everything has been made with gcc
3.3 and all works.

Thanks for the info on the shared libraries, I didn't know that, you've
saved me a lot of time. I guess you only learn about things like this
when they don't work and you have to fix them.

What's really confused me is the fact that I was definitely using gcc
3.4 on my old (deleted) RHEL4 that was linking everything together. It
was also compiling my code much faster as well. A quick ldd on a backup
executable shows that I did in fact get both libstdc++.so.5 & so.6
linked in together and working, and I didn't even know it!

Thanks once again
John

On Fri, 2007-04-27 at 07:54 -0700, Brian Dessent wrote:
> John Morris wrote:
> 
> > My programme compiles and links fine using a RHEL3 PC, gcc 3.4 with
> > libstdc++.so.5. It runs reasonably well and I am happy.
> 
> Are you sure that's not 3.2 or 3.3 that your old RH system was using? 
> According to <http://gcc.gnu.org/onlinedocs/libstdc++/abi.html>, the
> last version that used v5 was gcc v3.3.3.
> 
> > I have just changed my laptop (different from PC above) from RHEL3 to
> > ubuntu as everything about it looks and feels nicer. However, ubuntu
> > ships with libstdc++.so.5 and libstdc++.so.6, both in /usr/lib. I have
> > got gcc 3.4.
> > 
> > My code compiles under ubuntu, but it is linking the libstdc++.so.6 into
> > everything instead of libstdc++.so.5. This causes me great problems and
> > my programme dies almost straight away. I use 3rd party open-source
> > software which relies on libstdc++.so.5 and I will need to run it on the
> > RHEL3 machine mentioned before, that only has libstdc++.so.5.
> > 
> > Does anybody know what flag I need to set in my Makefile to get
> > everything linked with libstdc++.so.5? I can't have any trace of libstdc
> > ++.so.6, 'ldd me.exe | grep libstdc++.so.6' has to come up blank.
> 
> You can't just pick and choose which version of the library is used.  It
> is highly coupled to the version of gcc; in other words, the version of
> gcc that you use will determine which version of libstdc++ your code
> gets linked to, and nothing else.  They go hand in hand.
> 
> Generally when you are aiming for binary compatibility across multiple
> systems/platforms, the only way to achieve this is to set the compile
> environment to the oldest combination of libraries and compilers that
> you want to support.  There is no way to go backwards, i.e. use a recent
> gcc but link to an older library.  If you want to produce binaries that
> still link against an older libstdc++ you'll have to install gcc 3.3 on
> your system and use that.  The libstdc++.so.5 that ubuntu provides is
> for compatibility for existing binaries that were compiled with gcc 3.3,
> it is not possible to link against it for new programs compiled with gcc
> 3.4 or 4.x.
> 
> Brian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux