Shared Libraries in Same Folder with App in TCSH
Two simple options.
You can set the
LD_LIBRARY_PATH
variable inside your script (see Section 3.3.1. of the shared libraries HOWTO). There are problems with this approach for production code, but if set in a wrapper script is probably ok.You can call your app with the libraries specified on the command line by invoking the
ld-linux
program loader directly, as described in the manpage and HOWTO:/lib/ld-linux.so.2 --library-path PATH EXECUTABLE
Porting a Unix program from one host to another
I think your best bet, given the circumstances, is to compile a static binary; see the -static
option of gcc
. However, this has downsides and might not always work.
You could also try to copy the shared libraries, but then you need to instruct the dynamic loader to search for the libraries in the location where you added them (your binary will have to be linked with the -Wl,-rpath,/path/to/libs
switch.
Try the -static
first. It should be easier.
If you wanna take a deeper look into the issues of binary portability, check out sources like:
- http://www.evanjones.ca/portable-linux-binaries.html
- http://freegamedev.net/wiki/Portable_binaries
- Compiling C++ into portable linux binaries
- google "linux binary portability"
Why do I have to define LD_LIBRARY_PATH with an export every time I run my application?
Use
export LD_LIBRARY_PATH="/path/to/library/"
in your .bashrc otherwise, it'll only be available to bash and not any programs you start.
Try -R/path/to/library/
flag when you're linking, it'll make the program look in that directory and you won't need to set any environment variables.
EDIT: Looks like -R
is Solaris only, and you're on Linux.
An alternate way would be to add the path to /etc/ld.so.conf
and run ldconfig
. Note that this is a global change that will apply to all dynamically linked binaries.
How do I get rid of LD_LIBRARY_PATH at run-time?
As suggested by Richard Pennington, the missing library is not used directly by my application, but it is used by the shared libraries I use. Since I cannot recompile IPP, the solution to my problem is to add -liomp5
when compiling, using the -R option for the linker. This actually adds the rpath for libiomp5.so fixing the problem!
Will an executable moved to another directory still work?
As long as the executable can find it's dependencies (other dlls on Windows for example) then it will work. If it can't for any reason (i.e. it assumes that they are in the same directory) then it won't.
Unfortunately the error messages you get out of Windows aren't always the most helpful so you might have problems locating all the required files.
Related Topics
How to Identify Padding Scheme Used in Rsa Signature of a Certificate, Using Openssl
How to Invoke Any Kernel Function
Getting "Permission Denied" on Dirname and Basename
How to Change Port Gitlab on Centos 6
Do Here-Strings Undergo Word-Splitting
How to Find Performance of Individual Functions in a Process Using Perf Tool
How to Copy from Tmux (Copy Mode) Running on a Remote Ssh Connection to Your Local Clipboard
Compare Two Different Urls Using Linux
Systemd Enabled Services Not Starting at Boot Anymore
Can Not Route Packets from One Interface to Another
Example of Using External Libraries or Packages in Common Lisp
Install Ssh Server on Embedded Device
Mongodb (Result= Signal, Code = Killed, Signal = Ill
Echo - Syntax Error: Bad Substitution
Check What Conda Environment Is Currently Activated