Linux: error while loading shared libraries

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
specy
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Oct 20, 2010 12:10 am
Location: Netherlands
Contact:

Linux: error while loading shared libraries

Post 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: libwx_gtk2u_richtext-2.8.so.0: cannot open shared object file: No such file or directory
although it's on my system:

Code: Select all

darkbyte@lenovo:/usr/lib$ ls | grep libwx_gtk2u_richtext-2.8.so.0
libwx_gtk2u_richtext-2.8.so.0
libwx_gtk2u_richtext-2.8.so.0.7.0
I've installed it with the libwxgtk2.8-dev package. Strange. :?
What am I missing here?


The program binary itself can be downloaded here: http://www.stereotool.com/download/ster ... 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/6.1.2.051/ia32/include/ -L"/opt/intel/ipp/6.1.2.051/ia32/lib/" -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
linux-gate.so.1 => (0x00e85000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00acf000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x001f5000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00776000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x0021b000)
/lib/ld-linux.so.2 (0x00d10000)
owello@owello-desktop:~/Downloads$ ldd ./stereo_tool_gui_BETA510-32
linux-gate.so.1 => (0x00232000)
libwx_gtk2u_richtext-2.8.so.0 => /usr/lib/libwx_gtk2u_richtext-2.8.so.0 (0x00de6000)
libwx_gtk2u_aui-2.8.so.0 => /usr/lib/libwx_gtk2u_aui-2.8.so.0 (0x00a6a000)
libwx_gtk2u_xrc-2.8.so.0 => /usr/lib/libwx_gtk2u_xrc-2.8.so.0 (0x002ee000)
libwx_gtk2u_qa-2.8.so.0 => /usr/lib/libwx_gtk2u_qa-2.8.so.0 (0x001be000)
libwx_gtk2u_html-2.8.so.0 => /usr/lib/libwx_gtk2u_html-2.8.so.0 (0x00912000)
libwx_gtk2u_adv-2.8.so.0 => /usr/lib/libwx_gtk2u_adv-2.8.so.0 (0x00381000)
libwx_gtk2u_core-2.8.so.0 => /usr/lib/libwx_gtk2u_core-2.8.so.0 (0x00598000)
libwx_baseu_xml-2.8.so.0 => /usr/lib/libwx_baseu_xml-2.8.so.0 (0x00dbf000)
libwx_baseu_net-2.8.so.0 => /usr/lib/libwx_baseu_net-2.8.so.0 (0x0049b000)
libwx_baseu-2.8.so.0 => /usr/lib/libwx_baseu-2.8.so.0 (0x00ad9000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00c26000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x00f29000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00110000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0x0012f000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00f4f000)
libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x04dbd000)
libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x00233000)
libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x00148000)
libgio-2.0.so.0 => /usr/lib/libgio-2.0.so.0 (0x004c7000)
libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0 (0x00164000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x009e9000)
libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x001de000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00d1c000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x0018b000)
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x0043e000)
libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x00221000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x009e1000)
librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0x00226000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x16310000)
libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0x002c9000)
libSM.so.6 => /usr/lib/libSM.so.6 (0x002cd000)
libpng12.so.0 => /lib/libpng12.so.0 (0x00eff000)
libz.so.1 => /lib/libz.so.1 (0x002d6000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x009ae000)
libtiff.so.4 => /usr/lib/libtiff.so.4 (0x00a03000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0x0047d000)
libexpat.so.1 => /lib/libexpat.so.1 (0x00d92000)
/lib/ld-linux.so.2 (0x0057b000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x00481000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00491000)
libXi.so.6 => /usr/lib/libXi.so.6 (0x00565000)
libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x00573000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x008f7000)
libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0x00901000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x0e3ac000)
libXcomposite.so.1 => /usr/lib/libXcomposite.so.1 (0x0090d000)
libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0x009cf000)
libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x009d3000)
libcairo.so.2 => /usr/lib/libcairo.so.2 (0x06721000)
libpcre.so.3 => /lib/libpcre.so.3 (0x037ca000)
libresolv.so.2 => /lib/tls/i686/cmov/libresolv.so.2 (0x00dca000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00ed3000)
libICE.so.6 => /usr/lib/libICE.so.6 (0x08b9f000)
libuuid.so.1 => /lib/libuuid.so.1 (0x009d9000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x1ca6f000)
libpixman-1.so.0 => /usr/lib/libpixman-1.so.0 (0x0698d000)
libdirectfb-1.2.so.0 => /usr/lib/libdirectfb-1.2.so.0 (0x12be4000)
libfusion-1.2.so.0 => /usr/lib/libfusion-1.2.so.0 (0x00a5e000)
libdirect-1.2.so.0 => /usr/lib/libdirect-1.2.so.0 (0x17ce4000)
libxcb-render-util.so.0 => /usr/lib/libxcb-render-util.so.0 (0x00db9000)
libxcb-render.so.0 => /usr/lib/libxcb-render.so.0 (0x00dde000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00eee000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00ef2000)
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,

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.

Regards,

David
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

http://wiki.wxwidgets.org/Compiling_and ... s_projects also sounds useful; but listen to David first, his post was quite detailed and useful :)
"Keyboard not detected. Press F1 to continue"
-- Windows
qgranfor
Experienced Solver
Experienced Solver
Posts: 89
Joined: Sun Aug 29, 2004 7:32 pm
Location: ND...USA
Contact:

Post by qgranfor »

Have you run ldconfig as root to pick up the new shared libs?
AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post 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.
Post Reply