How to install the program depending on libstdc ++ library
My program is written in C ++ using GCC on Ubuntu 9.10 64 bit. If it depends on / usr / lib 64 / libstdc ++. So.6 which actually points to / usr / lib 64 / libstdc ++. So.6.0.13. Now I am copying this program to a virgin Ubuntu 7.04 system and trying to run it. It doesn't work as expected. Then I add the following files to the program directory:
- libstdc ++. So.6.0.13
- libstdc ++. so.6 (links to libstdc ++. so.6.0.13)
Run command:
LD_LIBRARY_PATH=. ./myprogram
Now everything is all right. The question is, how can I write an install script for such a program? The myprogram file itself must be placed in / usr / local / bin. What can I do with dependencies? For example, on the destination computer, / usr / lib 64 / libstdc ++. So.6 points to / usr / lib 64 / libstdc ++. So.6.0.8. What can I do about it?
Note: the program is closed, I cannot provide the source code and makefile.
a source to share
If you are working on Ubuntu creating a .deb (Debian Package) seems to be fine. Here is the link to get started.
Your package will say it depends on some other packages (usually packages that include libstdc++.so.6.0.13
- I think the package name is something like libstdc++
) and the dependencies will be installed when you install your own package with dpkg -i <yourpackage>.deb
.
Then you can remove it with dpkg -r <yourpackage>
.
Never ship such standards files to your own archive anyway . Dependencies exist for this specific purpose.
Hope it helps.
a source to share
The real problem is when you are trying to install a binary that uses newer versions of the shared libraries that are available in Ubuntu 9.10. The best option should be to create a specific target for the old Ubuntu 7.10 compile it with the old libraries (this is the backport).
Then you have to 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 correct version of libstdc ++ and other required libraries. You just set this environment variable in your startup shell script. In your script, you check if new libraries are available or not, and you set LB_LIBRARY_PATH (say / usr / local / lib / myprogram /) only when needed. But as other posters have said, this is very bad practice. Anyway, never try to put these provided libraries in their default location in Ubuntu 9.10, you risk dropping the target system and causing update issues for users or your program if these libraries are officially sent back.
But if you choose to include your own set of system libraries, there is still one more way than the previous one: just link these libraries statically. If the program is the only user of the library, as it is likely to be in the above scenario, you will lose all the benefits of using a shared dynamic library, then why use it at all? And with statically linked libraries, you don't have to install them.
a source to share