ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I try to execute a program. It gives me this "cannot open shared object file: No such file or directory" error...
I know I can add it to ld.so.conf and run ldconfig. But that's not what I want... For example on windows you can just copy the responsible "dll" to the executable directory and it works as well.
But how can I achieve the same in Linux? I tried already making a softlink with the same name to the executable directory, but that didn't work...
Maybe create the softlink into a directory that is always checked for libs, like /usr/lib for example? Or define the library variable manually with export.. (note: I don't remember what it's exactly called, check using console).
If you are the developer of the program, use -rpath-linkpath and -rpathpath when linking. -rpath-link provides a search path for link resolution to make sure you have a good link, but does nothing for run-time. When you use -rpath, that adds a path to the binary so that at run-time ld will search that path for dependent libraries.
ta0kira
Example: program needs library libprogram.so which is located at ../lib from the build directory, and after installation it will be located in the same path as program. You would use -rpath-link ../lib -rpath . when linking program to libprogram.so.
ta0kira
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.