Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile C++ for various Ubuntu versions

Tags:

c++

ubuntu

We are building a program under Linux which works within a specific Ubuntu version just fine. But we would like to have the same binary running on Ubuntu 10.04 and 11.10. It would be completly ok to build the application on the 10.04 platform. But when I do this, I have dependencies to specific library versions (eg. libboost_thread.so.1.40.0) which are not aviable on 11.10 because it uses newer versions. The system is build using QMake.

I am looking for a tutorial or starting point how to solve these dependency conflicts for multiple Ubuntu platforms.

like image 595
Matthias Avatar asked Feb 17 '12 13:02

Matthias


1 Answers

If nobody else feels like taking a swing at this I may as well inject something.

I am going to make a few assumptions.

  • You are distributing a binary/closed source application
  • You want to distribute it yourself

Thus ruling out the whole "just let the distro/users build it for their setup themselves".

Looking at how others have resolved similar issues I can see that it is common to include the shared libraries with your application and then use a loader/wrapper, what you want to call it, script that modifies the environment before launching the application. Specifically they modify the LD_LIBRARY_PATH to include the /lib folder included with the application.

The script could be as simple as.

#!/bin/sh

LD_LIBRARY_PATH=./lib ./myAppReal

That is how I solved distributing a Qt4 application to users having distributions not shipping newer than Qt-3.3.6 (in 2009... seriously). Edit: Might also say by users I mean the 5-ish people at the company paying for development, spec failure on our part not asking them to be more specific when they said cross-platform on modern operating systems.

Now someone will probably find about a dozen things wrong with this, but that's good, I can update and learn as we go.

EDIT: As JimR said this comes with security implications, if you leave your libs folder world writable someone may use it to inject malicious code into your application. Depending on how you plan on deploying it may or not be a real issue, but you should be aware of it.

like image 105
r_ahlskog Avatar answered Nov 07 '22 09:11

r_ahlskog