Page 1 of 1

Linux: error while loading shared libraries

Posted: Wed Oct 20, 2010 12:22 am
by specy
Platform: Linux
Compiler: GCC version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)
wxWidgets version: 2.8

I have succesfully built a GUI application that I converted from Windows to Linux using wxWidgets, because I wanted to offer a Linux (and later maybe also a MAC) version of my audio processing software. On my own system, it runs flawless.

However, I have problems when I send it to others. I've tried running it in another Linux VMware image on my system, and it immediately aborts with a segmentation fault.

Someone else tried to run it and he wrote:
Mod: i have some problems launching it. I get:

Code: Select all

./stereo_tool_gui_BETA30: error while loading shared libraries: cannot open shared object file: No such file or directory
although it's on my system:

Code: Select all

[email protected]:/usr/lib$ ls | grep
I've installed it with the libwxgtk2.8-dev package. Strange. :?
What am I missing here?

The program binary itself can be downloaded here: ... BETA510-32

I'm building with the following command:
g++ -O3 -fexpensive-optimizations -ffast-math -fomit-frame-pointer -fstrict-aliasing -fno-math-errno -freciprocal-math -fno-signed-zeros -fno-trapping-math -fassociative-math -DSSE2 -Dno_ST_WINDOWS -D_ST_GUI -o ../stereo_tool_SAlin ALL_MY_CPP_FILES.cpp -I/opt/intel/ipp/ -L"/opt/intel/ipp/" -march=pentium4 -msse2 -lippscmerged -lippsrmerged -lippsmerged -lippcore -lm `wx-config --libs` `wx-config --cxxflags`

`wx-config --libs` returns:
-pthread -Wl,-Bsymbolic-functions -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8

`wx-config --cxxflags` returns:
-I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread

LDD output: (doesn't -lbla mean that library libbla is linked in and hence not needed on the target system???)
$ ldd ./stereo_tool_BETA510-32 => (0x00e85000) => /usr/lib/ (0x00acf000) => /lib/tls/i686/cmov/ (0x001f5000) => /lib/ (0x00776000) => /lib/tls/i686/cmov/ (0x0021b000)
/lib/ (0x00d10000)
[email protected]:~/Downloads$ ldd ./stereo_tool_gui_BETA510-32 => (0x00232000) => /usr/lib/ (0x00de6000) => /usr/lib/ (0x00a6a000) => /usr/lib/ (0x002ee000) => /usr/lib/ (0x001be000) => /usr/lib/ (0x00912000) => /usr/lib/ (0x00381000) => /usr/lib/ (0x00598000) => /usr/lib/ (0x00dbf000) => /usr/lib/ (0x0049b000) => /usr/lib/ (0x00ad9000) => /usr/lib/ (0x00c26000) => /lib/tls/i686/cmov/ (0x00f29000) => /lib/ (0x00110000) => /lib/tls/i686/cmov/ (0x0012f000) => /lib/tls/i686/cmov/ (0x00f4f000) => /usr/lib/ (0x04dbd000) => /usr/lib/ (0x00233000) => /usr/lib/ (0x00148000) => /usr/lib/ (0x004c7000) => /usr/lib/ (0x00164000) => /usr/lib/ (0x009e9000) => /usr/lib/ (0x001de000) => /usr/lib/ (0x00d1c000) => /usr/lib/ (0x0018b000) => /usr/lib/ (0x0043e000) => /usr/lib/ (0x00221000) => /usr/lib/ (0x009e1000) => /lib/tls/i686/cmov/ (0x00226000) => /lib/ (0x16310000) => /usr/lib/ (0x002c9000) => /usr/lib/ (0x002cd000) => /lib/ (0x00eff000) => /lib/ (0x002d6000) => /usr/lib/ (0x009ae000) => /usr/lib/ (0x00a03000) => /lib/tls/i686/cmov/ (0x0047d000) => /lib/ (0x00d92000)
/lib/ (0x0057b000) => /usr/lib/ (0x00481000) => /usr/lib/ (0x00491000) => /usr/lib/ (0x00565000) => /usr/lib/ (0x00573000) => /usr/lib/ (0x008f7000) => /usr/lib/ (0x00901000) => /usr/lib/ (0x0e3ac000) => /usr/lib/ (0x0090d000) => /usr/lib/ (0x009cf000) => /usr/lib/ (0x009d3000) => /usr/lib/ (0x06721000) => /lib/ (0x037ca000) => /lib/tls/i686/cmov/ (0x00dca000) => /lib/ (0x00ed3000) => /usr/lib/ (0x08b9f000) => /lib/ (0x009d9000) => /usr/lib/ (0x1ca6f000) => /usr/lib/ (0x0698d000) => /usr/lib/ (0x12be4000) => /usr/lib/ (0x00a5e000) => /usr/lib/ (0x17ce4000) => /usr/lib/ (0x00db9000) => /usr/lib/ (0x00dde000) => /usr/lib/ (0x00eee000) => /usr/lib/ (0x00ef2000)

Posted: Wed Oct 20, 2010 9:39 am
by DavidHart

There are two possible reasons for that error message; in your case it's almost certainly the second.

1) It's common to get that error on e.g. ubuntu when you build your own wxGTK and install it to the default location, /usr/local. It seems that /usr/local/lib isn't one of the places where ubuntu looks for shared libs, so when you run a wx app, it can't find its libs. (One solution is to set LD_LIBRARY_PATH to /usr/local/lib in the terminal, or in ~/.bashrc).

2) You can't rely on a binary built on one Linux distro/version to run on another distro/version. Why not? Sometimes it's because of the system libs e.g. libc being incompatible. However I'd guess that in your case, it's because the other distro package has installed wxGTK to a different location (perhaps /opt or /usr/lib32 (or 64)) when yours is in /usr/lib; or vice versa. Your app will have linked using the -rpath value from wx-config, so will be looking for wx libs in the wrong place.

Which is why universal binaries are rare in Linux. Instead it's standard practice to build and distribute a separate binary for each target version of each distro; ideally in the package format (deb, rpm etc) that the distro uses.

BTW, there's a very helpful link that explains this and more, including how to get much more information out of ldd.



Posted: Wed Oct 20, 2010 3:04 pm
by Auria ... s_projects also sounds useful; but listen to David first, his post was quite detailed and useful :)

Posted: Mon Oct 25, 2010 7:14 pm
by qgranfor
Have you run ldconfig as root to pick up the new shared libs?

Posted: Mon Nov 22, 2010 10:43 pm
by AUser
you could use strace to see exactly what is going on.. Its possible that (1) the internal soname does not match, even though the filename does (this would be a pretty hefty bug...) (2) the gtk lib is trying to open other libs, but cannot find some dependency.