7

I have program using gtkmm, gtkglextmm and exiv2.

I want to include these libraries with the executable, because the app will not work if user doesn't has them on his/her system. On Windows .dll files solved the matter (I put them in the same directory as output file).

How to attached similar libraries on Linux? Is there any tool helping with that? I cannot force user to install dependencies.

Marco
  • 582
  • 1
  • 6
  • 17
  • 3
    On Linux, the equivalent of a .dll is a "dynamic shared object", or a .so. You could statically link the required libraries in your executable, but that is really not best practice. See David Heffernan's answer. You do not need to force the user to install the dependencies; you simply tell the user that it is their choice and they cannot run your application without those dependencies. – William Pursell Nov 22 '11 at 13:49
  • If your program is free software (e.g. GPL or LGPL licensed) you'll probably get help to package it within major distributions (and sometimes even, some nice person package it for you). – Basile Starynkevitch Nov 22 '11 at 14:10
  • William I have read somewhere that You can't do static linking with gtk (and gtkmm). I wonder if it is true... Also, as I've written below David Heffernan' answer - I need to make this program working even if user is too lazy to install dependencies by himself. – Marco Nov 22 '11 at 14:52

3 Answers3

14

Standard practice on Linux is not to redistribute your dependencies. Doing so just creates large amounts of duplication. You should instead specify the dependencies in your installation package and let the package manager resolve them.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 2
    Well I NEED to get my program working on Linux and someone is to lazy to install dependencies. I know what is the standard practicebut I need to get this done like with dlls on Windows. – Marco Nov 22 '11 at 14:47
  • 7
    This is not Windows. It is trivial to install the packages with your preferred package manager. That simply is the way to do it. Don't fight the platform. – David Heffernan Nov 22 '11 at 16:08
  • @DavidHeffernan Let's say I have a custom standalone platform. (Like a custom build of LFS for embedded devices.) How would you package the application then? – Balázs Börcsök Jul 19 '22 at 11:26
10

Better yet, use the package system of the distribution[s] you want to target, e.g. .deb packaging on Debian/Ubuntu/Mint (with aptitude or apt-get, themselves using dpkg), Yum/Rpm on Redhat/Fedora, etc etc.

DLL-s are called shared libraries (files named *.so) on Linux (in ELF format, use objdump, nm ... to explore them, and gcc -fPIC -shared to build them). They can be programmatically loaded with dlopen & dlsym. Beware that there are important differences between windows DLL-s & Linux *.so (dynamic linking don't have the same meaning on Windows & Linux)

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0

You can write simple sh script to start your program:

#!/bin/sh
LD_LIBRARY_PATH=/path/to/intall/directory
path/to/your/exe

and put so libraries to /path/to/intall/directory

fghj
  • 8,898
  • 4
  • 28
  • 56
  • 1
    That don't solve the dependency issues (details vary with distributions), and I don't recommend doing that. – Basile Starynkevitch Nov 22 '11 at 14:11
  • Why? ABI of basic things like glibc changed seldom, as things like X11 protocol. So if have other "so" libraries with your app, you can run it without problems. Now imagine situation, when you use something like qt 4.6, and you need show how you application looks like to user. But user have only ancient debian machine. What do you do, update all system to run your application once? – fghj Nov 22 '11 at 14:49
  • Yes, because Qt has so much dependencies that it is not worth solving them manually. If needed, run a "new" system in a chroot-ed environment -but even that won't work with an ancient kernel and a recent libc – Basile Starynkevitch Nov 22 '11 at 14:52
  • Who told to do it manually? You can use "ldd" any script language to gather all dependicies. – fghj Nov 22 '11 at 17:17
  • I'm not sure it would be simpler (in the general case) than depending upon a package manager provided by the distribution. – Basile Starynkevitch Nov 22 '11 at 17:20
  • For example, openoffice and matlab binary packages contains all ".so" library that they require. – fghj Nov 22 '11 at 17:21