4

I have an Ubuntu 12.04 64bit server setup under Hyper-V. I have installed Pervasive 64bit SQL drivers so that a stock-updater script can run daily (Updates external MySQL database from another local server running Exchequer software / PSQL database).

These drivers seem to conflict, as I found out when trying to run any apt-get commands:

apt-get update
apt-get: /usr/local/psql/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by apt-get)
apt-get: /usr/local/psql/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by apt-get)
apt-get: /usr/local/psql/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by apt-get)
apt-get: /usr/local/psql/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/x86_64-linux-gnu/libapt-pkg.so.4.12)
apt-get: /usr/local/psql/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /usr/lib/x86_64-linux-gnu/libapt-pkg.so.4.12)
apt-get: /usr/local/psql/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/x86_64-linux-gnu/libapt-pkg.so.4.12)

Any help would be great.

Alexander Holsgrove
  • 237
  • 1
  • 3
  • 15

2 Answers2

5

It looks like you or the installer have added /usr/local/pgsql/lib64/ to /etc/ld.so.conf or to the LD_LIBRARY_PATH environment variable. If it's in ld.so.conf remove it and run ldconfig. Ditto if it's in the default LD_LIBRARY_PATH - check /etc/environment, the system-wide startup scripts, your .bashrc and .bash_profile etc to see where it might've been added.

It's a terrible idea to have an incompatible libstdc++ on the library search path. If Pervasive's installer did this, report a bug, it's totally unacceptable and (as you've discovered) can break your system.

Once it's no longer on your library search path everything else will resume working, but the drivers won't work. You might be able to get them to work by running the program that uses them with a wrapper script that sets LD_LIBRARY_PATH="/usr/local/pgsql/lib64/:${LD_LIBRARY_PATH}" but only if those programs themselves do not require the other libstdc++.


A wrapper script can be as simple as:

#!/bin/sh
set -e
LD_LIBRARY_PATH="/usr/local/pgsql/lib64/:${LD_LIBRARY_PATH}"
/path/to/my/program "$@"

"$@" is a "magic" variable that expands into the original arguments passed to the shell script. Save the script as, say, myprogram_wrapper.sh, edit /path/to/my/program to point to the location of the application executable you want to launch, and use chmod a+x my_program_wrapper.sh to make it executable. You can then launch the app with ./my_program_wrapper.sh or add that wrapper to desktop shortcuts etc in place of the original application.

This is how lots of software that's bundled as binaries, like Adobe Reader, launches its self with its bundled libraries without affecting the rest of the system. It's not the best way (that's to use rpath linking) but it's OK.

Craig Ringer
  • 10,553
  • 9
  • 38
  • 59
  • Thanks craig - I found a solution that works for me (see my answer) but yours is more correct (hence accepting it) as it leads to a properly working system rather than a hack just to get PSQL/APT to work. The PSQL lib was added by me after following a guide here: http://cs.pervasive.com/forums/p/14171/48829.aspx. I don't know enough to setup that wrapper script. – Alexander Holsgrove Nov 23 '12 at 10:19
  • @AlexHolsgrove Added a quick note on a simple wrapper script. *please* comment on that forum thread and direct people here, you should *not* be globally modifying `ld.so.conf` like that! – Craig Ringer Nov 23 '12 at 10:32
3

Someone on the Pervasive forums suggested this fix:

Due to some versions conflicts I needed to move some files to be able to run "apt-get" without complaining about versions.

sudo mv /usr/local/psql/lib/libgcc_s.so.1 /usr/local/psql/lib/libgcc_s.so.1.org

sudo mv /usr/local/psql/lib/libstdc++.so.6 /usr/local/psql/lib/libstdc++.so.6.org

and after that not run "sudo ldconfig"

This works, but after reading @CraigRinger's answer, I think it seems a bit of a hack. Unfortunately I don't know enough to be able to implement the LD_LIBRARY_PATH fix.

Alexander Holsgrove
  • 237
  • 1
  • 3
  • 15