Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link with an older version of libstdc++

Tags:

c++

linux

linker

After installing a new build machine, I found out it came with 6.0.10 of the standard C++ library

-rw-r--r--  1 root root 1019216 2009-01-02 12:15 libstdc++.so.6.0.10 

Many of our target machines, however, still use an older version of libstdc++, for example:

-rwxr-xr-x 1 root root  985888 Aug 19 21:14 libstdc++.so.6.0.8 

Apparently the ABI changed in those last two 0.0.1's, as trying to run a program results in

/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found 

I tried explicitly installing an older version of gcc but that didn't help. Upgrading the target machines is out of my control, so not an option. What's the best way to get my builds to work on machines with an older libstdc++?

I searched in apt-cache for older libstdc++ versions to install, but apparently no older versions of 6 are available?

like image 237
Pieter Avatar asked Jan 18 '10 10:01

Pieter


1 Answers

You don't need to link to a different library, you need to use an older version of the compiler.

Have a look at the GNU ABI policy. The libstdc++ shared library is designed to be forward compatible. I.e. version 6.0.10 can be used if you need 6.0.8. In the policy you can read that from gcc-4.2.0 on, 6.0.9 is needed, so you need a gcc-4.1.x.

In short, that's why there's only one libstdc++.so.6.0.x on your system, you only need the latest.

As for setting up your build system to use only a specific version of the compiler: make sure the standard g++ can't be used (rename the link, remove the package providing it, take it out of PATH), and start digging. Worked for me.

like image 68
Jan Avatar answered Sep 20 '22 15:09

Jan