Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Shared libraries path

Brian_Allison
Beginner
396 Views
How come on my Mac OS X, when I create a dylib file and run my executable it knows to look ion the same folder for the dylib, but on Linux when it looks for the .so it does not know where to look for it?
0 Kudos
2 Replies
TimP
Honored Contributor III
396 Views
It's generally considered undesirable (vulnerable to malicious hacks) to include current directory in PATH and LD_LIBRARY_PATH by default (at least under bash, which often is the default shell). You can read further about this by starting up your search engine.
0 Kudos
John4
Valued Contributor I
396 Views

As tim18 said, the current directory shouldn't be added to the $PATH, and some commands even enforce the rule (e.g., find). The $LD_LIBRARY_PATH is expected to be used for compilation purposes only, but its use is discouraged at runtime.

However, the directory in which the executable lies can be added to the runtime path during the linking. You can make the compiler pass it as an option to the linker, with the following flags:

-Wl,-z,origin -Wl,-rpath,\$ORIGIN

0 Kudos
Reply