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.
Originally posted by lyle_s Given that you have a shared object in /some/nonstandard/place you have two options:
Place /some/nonstandard/place in /etc/ld.so.conf and run the ldconfig command (as root).
Place /some/nonstandard/place in the environment variable LD_LIBRARY_PATH.
For more, see man ld.so.
Lyle
Absolutly not! I don't want to use ldconfig in anyway... LD_LIBRARY_PATH would work if I could change it upon startup in my program... except my program doesn't start... so problem.
I have already tried your idea itsme86... It won't compile, and just says "undefined reference" to every function in the lib...
I DO NOT WANT TO CHANGE/EDIT/MODIFY ANY SYSTEM SETTINGS!
Dynamic linking would be fine if anyone would show me how to do it. But it has to be Windows/Linux compatible, and it has to be easy. You know, not like:
You could make it a static .a library instead. Another option might be to look at functions like dlopen, dlsym, etc. I haven't used those myself, but a quick look at the man page suggests they are similar to the Win32 API functions LoadLibrary and GetProcAddress...
Originally posted by Mara itsme86's suggestion should work.
It'd work to compile and link, but not to run. When run, it would look for the .so file somewhere in the library paths in /etc/ld.so.conf or $LD_LIBRARY_PATH.
Originally posted by deiussum You could make it a static .a library instead. Another option might be to look at functions like dlopen, dlsym, etc. I haven't used those myself, but a quick look at the man page suggests they are similar to the Win32 API functions LoadLibrary and GetProcAddress...
Ya... But when I tried this, I had to dlsym EVERY function in the library to a LIST of pointers... this sucked a million times over! So if there is an easy way... sure!
Originally posted by deiussum It'd work to compile and link, but not to run. When run, it would look for the .so file somewhere in the library paths in /etc/ld.so.conf or $LD_LIBRARY_PATH.
So then make it a static library file so that it isn't needed at all by the final binary.
Either that or you are going to have to put the path to it in ld.so.conf or the LD_LIBRARY_PATH and run ldconfig. I don't think there's any other choice, though I could be mistaken.
Originally posted by The_Nerd It compiled. But wouldn't link.
Is your file called libmylib.so? When you use -llibraryname it expects it to be pre-pended with the lib. Still, even if you get it to link you are going to probably going to run into problems when you try to run the app, as we've been telling you...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.