views:

113

answers:

2

My program is written in C++, using GCC on Ubuntu 9.10 64 bit. If depends on /usr/lib64/libstdc++.so.6 which actually points to /usr/lib64/libstdc++.so.6.0.13. Now I copy this program to virgin Ubuntu 7.04 system and try to run it. It doesn't run, as expected. Then I add to the program directory the following files:

libstdc++.so.6.0.13
libstdc++.so.6 (links to libstdc++.so.6.0.13)

and execute command:

LD_LIBRARY_PATH=. ./myprogram

Now everything is OK. The question: how can I write installation script for such program? myprogram file itself should be placed to /usr/local/bin. What can I do with dependencies? For example, on destination computer, /usr/lib64/libstdc++.so.6 link points to /usr/lib64/libstdc++.so.6.0.8. What can I do with this?

Note: the program is closed-source, I cannot provide source code and makefile.

+2  A: 

If you're working on Ubuntu, making a .deb (Debian Package) seems to way to go. Here is a link to get you started.

Your package will state it depends on some other packages (typically the packages that includes libstdc++.so.6.0.13 - i guess the package name is something like libstdc++) and dependencies will be installed when you install your own package using dpkg -i <yourpackage>.deb.

Afterwards, you'll be able to uninstall it using dpkg -r <yourpackage>.

Anyway, never ship such standards files with your own archive. Dependencies exists for this exact purpose.

Hope it helps.

ereOn
What about non-Debian Linux distributions?
Alex Farber
@Alex Farber: You'll have to do a package using the package system(s) of the target(s) operating system(s). Since your project is closed source, you cannot provide autotools/autoconf scripts or assume that someone else will do a package for you (typically a debian package maintener).
ereOn
@Alex Farber: Many linux distributions support RPM. Self-extracting bash archives is also an option, although using native system installation packages like deb or rpm is better and cleaner solution
Dmitry Yudakov
@Dmitry Yudakov: nice point indeed. Moreover, there are tools (like `alien`) that can convert .rpm to .deb (and .deb to .rpm) if you really don't want to create both manually.
ereOn
+1  A: 

The real problem is that you try to install a binary that use newer versions os common libraries that the ones available on Ubuntu 9.10. The best option should be to make a specific target for the old Ubuntu 7.10 an compile it with the old libraries (that's a backport).

Then you should make two (or more) .deb packages, one for Ubuntu 9.10 and one for Ubuntu 7.10.

Another possibility is to continue doing what you are doing now : set LD_LIBRARY_PATH to point to the desired version of libstdc++ and other necessary libraries. You just set this environment variable in a launcher shell script. In you script you check if the new libraries are available or not and you set your LB_LIBRARY_PATH (say to /usr/local/lib/myprogram/) only if needed. But as others poster pointed out : that's a very bad practice. Anyway, never try to put these provided libraries at their standard place in Ubuntu 9.10, you would risk broking the target system and causing update problems for users or your program if these libraries are officially backported someday.

But if you choose to include your own set of system libraries there is still another way to go than the above one: just link these libraries statically. If a program is the only user of a library as it will probably be in the above scenario you'll lose all advantages of using a shared dynamic library, then why bother with using it at all ? And with stacically linked libraries you won't have to install them.

kriss
If the library version is really an issue, he still can compile it for the target operating system using the available `libstdc++`. Unless he needs a particular functionnality that only exists in libstdc++-.6.0.13: then yes, using a backport for it is the way to go.
ereOn
@ereOn: yes, that's I'm suggesting. But I wonder if the OP problem is not with building environment more than with installation. He either need a Ubuntu 7.10 env to compile or tweak it's compile environment settings to compile to other targets than 9.10.
kriss