LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-26-2014, 04:21 AM   #1
roundpotato
LQ Newbie
 
Registered: Jul 2013
Posts: 10

Rep: Reputation: Disabled
Unhappy Program development with shared libraries (OpenCV exe fails on another machine)


Hello,

I attempted to develop a simple camera viewer(using OpenCV 2.3.4) on my Debian 7 running on VirtualBox and run it on another machine(physical this time) without OpenCV and that is very minimalistic.

It ran fine where it was develepoed, but not on another machine. The executable is 11KB(obvious that it links to a bunch of ".so" shared libraries).

The obvious thing one would do is to copy the libraries along with the executable and install them as appropriate, which I tried to do until it kept asking and asking on about 7-th or 8-th execution, weird libraries like "libtbb.so" "libImath.so" etc.

I imagine it could have linked to tens of even a hundred of those. I can't just keep copying every single one it complaints about(discovering them from errors by executing the program on another machine).

I tried to google how to include all libraries from Eclipse C++ into an executable, but it seems you can't do that with shared libraries and enforcing "-static" flag brings millions of errors(seemingly of missing corresponding static libraries).

Even if I manage to somehow(still would be a huge help from current situation) copy all involved libraries automatically, I would still need to set up links or them in correct locations.

I doubt my case is unique as it seems to be a general notion of "developing under Linux with shared libraries".

Anyone has any ideas?
 
Old 06-26-2014, 06:08 AM   #2
turtleli
Member
 
Registered: Aug 2012
Location: UK
Posts: 206

Rep: Reputation: Disabled
Have you tried installing the static libraries? Debian provides static libraries in separate development packages e.g. libopencv-dev.
 
Old 06-26-2014, 06:15 AM   #3
roundpotato
LQ Newbie
 
Registered: Jul 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by turtleli View Post
Have you tried installing the static libraries? Debian provides static libraries in separate development packages e.g. libopencv-dev.
Yes.

Code:
apt-get -y install build-essential checkinstall git cmake libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev
apt-get -y install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg
apt-get -y install libopencv-dev
apt-get -y install build-essential checkinstall cmake pkg-config yasm
apt-get -y install libtiff4-dev libjpeg-dev libjasper-dev
apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev
apt-get -y install python-dev python-numpy
apt-get -y install libtbb-dev
apt-get -y install libqt4-dev libgtk2.0-dev libgtk2.0-0
apt-get -y install libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev
apt-get -y install v4l-utils
apt-get -y install libjpeg8 libjpeg8-dev
apt-get -y install x264 libx264-dev ffmpeg
 
Old 06-26-2014, 06:39 AM   #4
turtleli
Member
 
Registered: Aug 2012
Location: UK
Posts: 206

Rep: Reputation: Disabled
Since you have a working shared library version of the program, run "ldd program_name" to find out what shared libraries are used. Check you have all the corresponding static libraries just in case you missed some.

Can you post (or link to) the error messages that appear when you use the -static flag?
 
Old 06-26-2014, 08:34 AM   #5
roundpotato
LQ Newbie
 
Registered: Jul 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by turtleli View Post
Since you have a working shared library version of the program, run "ldd program_name" to find out what shared libraries are used. Check you have all the corresponding static libraries just in case you missed some.
It should be obvious to you from the output that the amount of libraries is ridiculous(96) to both copy and/or check and/or obtain static ones/etc.

ldd Camera > dependencies.txt (Also in Attachments)
Code:
	linux-vdso.so.1 =>  (0x00007fff197ff000)
	libopencv_core.so.2.4 => /usr/local/lib/libopencv_core.so.2.4 (0x00007f2965fff000)
	libopencv_highgui.so.2.4 => /usr/local/lib/libopencv_highgui.so.2.4 (0x00007f2965d69000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2965a61000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f29657df000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f29655c9000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f296523d000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2965021000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f2964e0a000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2964c05000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f29649fd000)
	libGLU.so.1 => /usr/lib/x86_64-linux-gnu/libGLU.so.1 (0x00007f2964790000)
	libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007f296452f000)
	libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007f2964328000)
	libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007f296410d000)
	libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f2963dd1000)
	libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f2963bbf000)
	libtbb.so.2 => /usr/lib/libtbb.so.2 (0x00007f2963991000)
	libopencv_imgproc.so.2.4 => /usr/local/lib/libopencv_imgproc.so.2.4 (0x00007f29634a8000)
	libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f296326e000)
	libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f2963047000)
	libtiff.so.4 => /usr/lib/x86_64-linux-gnu/libtiff.so.4 (0x00007f2962de0000)
	libjasper.so.1 => /usr/lib/x86_64-linux-gnu/libjasper.so.1 (0x00007f2962b85000)
	libImath.so.6 => /usr/lib/libImath.so.6 (0x00007f296297f000)
	libIlmImf.so.6 => /usr/lib/libIlmImf.so.6 (0x00007f29626c5000)
	libIex.so.6 => /usr/lib/libIex.so.6 (0x00007f29624a5000)
	libHalf.so.6 => /usr/lib/libHalf.so.6 (0x00007f2962262000)
	libIlmThread.so.6 => /usr/lib/libIlmThread.so.6 (0x00007f296205a000)
	libgstbase-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstbase-0.10.so.0 (0x00007f2961e05000)
	libgstreamer-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstreamer-0.10.so.0 (0x00007f2961b1d000)
	libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f29618cc000)
	libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f29616c8000)
	libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f29614c6000)
	libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f2961165000)
	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f2960e6d000)
	libgstapp-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstapp-0.10.so.0 (0x00007f2960c60000)
	libgstvideo-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstvideo-0.10.so.0 (0x00007f2960a42000)
	libdc1394.so.22 => /usr/lib/x86_64-linux-gnu/libdc1394.so.22 (0x00007f29607cd000)
	libv4l1.so.0 => /usr/lib/x86_64-linux-gnu/libv4l1.so.0 (0x00007f29605c7000)
	libavcodec.so.53 => /usr/lib/x86_64-linux-gnu/libavcodec.so.53 (0x00007f295f740000)
	libavformat.so.53 => /usr/lib/x86_64-linux-gnu/libavformat.so.53 (0x00007f295f439000)
	libavutil.so.51 => /usr/lib/x86_64-linux-gnu/libavutil.so.51 (0x00007f295f218000)
	libswscale.so.2 => /usr/lib/x86_64-linux-gnu/libswscale.so.2 (0x00007f295efcf000)
	libQtOpenGL.so.4 => /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4 (0x00007f295ecce000)
	libQtGui.so.4 => /usr/lib/x86_64-linux-gnu/libQtGui.so.4 (0x00007f295e017000)
	libQtTest.so.4 => /usr/lib/x86_64-linux-gnu/libQtTest.so.4 (0x00007f295ddf0000)
	libQtCore.so.4 => /usr/lib/x86_64-linux-gnu/libQtCore.so.4 (0x00007f295d91c000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2966471000)
	libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007f295d6f6000)
	libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f295d4f4000)
	libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f295d2ee000)
	libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f295d0ec000)
	libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007f295ced4000)
	libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f295ccb4000)
	libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f295caad000)
	libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f295c8a1000)
	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f295c69c000)
	libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f295c48d000)
	libffi.so.5 => /usr/lib/x86_64-linux-gnu/libffi.so.5 (0x00007f295c27f000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f295c05c000)
	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f295be1f000)
	liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0 (0x00007f295bba1000)
	libraw1394.so.11 => /usr/lib/x86_64-linux-gnu/libraw1394.so.11 (0x00007f295b992000)
	libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f295b781000)
	libv4l2.so.0 => /usr/lib/x86_64-linux-gnu/libv4l2.so.0 (0x00007f295b575000)
	libxvidcore.so.4 => /usr/lib/x86_64-linux-gnu/libxvidcore.so.4 (0x00007f295b23e000)
	libx264.so.123 => /usr/lib/x86_64-linux-gnu/libx264.so.123 (0x00007f295aeb5000)
	libvpx.so.1 => /usr/lib/x86_64-linux-gnu/libvpx.so.1 (0x00007f295ac16000)
	libvorbisenc.so.2 => /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f295a747000)
	libvorbis.so.0 => /usr/lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f295a519000)
	libtheoraenc.so.1 => /usr/lib/x86_64-linux-gnu/libtheoraenc.so.1 (0x00007f295a2d8000)
	libtheoradec.so.1 => /usr/lib/x86_64-linux-gnu/libtheoradec.so.1 (0x00007f295a0bc000)
	libspeex.so.1 => /usr/lib/x86_64-linux-gnu/libspeex.so.1 (0x00007f2959ea3000)
	libschroedinger-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libschroedinger-1.0.so.0 (0x00007f2959bd6000)
	libopenjpeg.so.2 => /usr/lib/x86_64-linux-gnu/libopenjpeg.so.2 (0x00007f29599b4000)
	libmp3lame.so.0 => /usr/lib/x86_64-linux-gnu/libmp3lame.so.0 (0x00007f2959729000)
	libgsm.so.1 => /usr/lib/x86_64-linux-gnu/libgsm.so.1 (0x00007f295951c000)
	libdirac_encoder.so.0 => /usr/lib/x86_64-linux-gnu/libdirac_encoder.so.0 (0x00007f295928c000)
	libva.so.1 => /usr/lib/x86_64-linux-gnu/libva.so.1 (0x00007f2959074000)
	librtmp.so.0 => /usr/lib/x86_64-linux-gnu/librtmp.so.0 (0x00007f2958e5a000)
	libgnutls.so.26 => /usr/lib/x86_64-linux-gnu/libgnutls.so.26 (0x00007f2958b9a000)
	libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f2958989000)
	libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f29586ea000)
	libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f29584e0000)
	libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f29582a9000)
	libaudio.so.2 => /usr/lib/x86_64-linux-gnu/libaudio.so.2 (0x00007f295808f000)
	libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f2957e8b000)
	libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f2957c86000)
	libv4lconvert.so.0 => /usr/lib/x86_64-linux-gnu/libv4lconvert.so.0 (0x00007f2957a0d000)
	libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0 (0x00007f2957807000)
	libgcrypt.so.11 => /lib/x86_64-linux-gnu/libgcrypt.so.11 (0x00007f2957588000)
	libtasn1.so.3 => /usr/lib/x86_64-linux-gnu/libtasn1.so.3 (0x00007f2957377000)
	libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f2957165000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f2956f3a000)
	libXt.so.6 => /usr/lib/x86_64-linux-gnu/libXt.so.6 (0x00007f2956cd3000)
	libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f2956acf000)

Quote:
Originally Posted by turtleli View Post
Can you post (or link to) the error messages that appear when you use the -static flag?
Yes, please see below.

build_log.txt
Attached to post because of character limit.
Attached Files
File Type: txt build_log.txt (141.8 KB, 11 views)
File Type: txt dependencies.txt (7.4 KB, 10 views)
 
Old 06-26-2014, 11:34 AM   #6
turtleli
Member
 
Registered: Aug 2012
Location: UK
Posts: 206

Rep: Reputation: Disabled
Quote:
Originally Posted by roundpotato View Post
It should be obvious to you from the output that the amount of libraries is ridiculous(96) to both copy and/or check and/or obtain static ones/etc.
Unless the other machines have all the necessary dependencies then you'll need to obtain and install the static libraries. I do not think there is an alternative.

From the build log I also think you need to explicitly link the library dependencies if you use -static. I see errors related to libraries that you already have static versions of.
 
Old 06-26-2014, 12:37 PM   #7
roundpotato
LQ Newbie
 
Registered: Jul 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by turtleli View Post
Unless the other machines have all the necessary dependencies then you'll need to obtain and install the static libraries. I do not think there is an alternative.

From the build log I also think you need to explicitly link the library dependencies if you use -static. I see errors related to libraries that you already have static versions of.
Well, I'm back where I'm started then. There is no way any person in his right mind would go over 100+ libraries, obtaining and/or linking them manually(and this is all just for ONE SPECIFIC LITTLE PROGRAM).
 
Old 06-27-2014, 04:14 AM   #8
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by roundpotato View Post
Well, I'm back where I'm started then. There is no way any person in his right mind would go over 100+ libraries, obtaining and/or linking them manually(and this is all just for ONE SPECIFIC LITTLE PROGRAM).
You can give a try to statifier - http://statifier.sf.net and/or Ermine - http://magicErmine.com
Both of them converts regular dynamically linked executable to self-containing one,
so you shouldn't mess with static linkage on one hand, and will need to copy only one file to the target machine on the other.

Statifier is GPL licensed, but have a trouble with VDSO randomization ( == a lot of modern systems ),
Ermine cope well with VDSO randomization, bit it's commercial
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenCV libraries warp perspective will this work mreff555 Programming 4 06-05-2012 01:55 PM
File Roller 2.32.0 fails to extract .exe file, yet on another machine it does RockSolidAfrican Ubuntu 4 11-14-2011 05:15 AM
[SOLVED] chroot fails with "error while loading shared libraries" b_senthilbe Linux - Software 3 02-07-2011 05:01 PM
chroot fails with "error while loading shared libraries" b_senthilbe Linux - Newbie 3 02-05-2011 01:00 PM
How to see which shared libraries are linked to a program zsjoska Linux - Newbie 2 11-19-2004 01:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration