ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Everything in this post is off the top of my head.
How do I make any program (that I write) look for libraries in the running folder (or any specific one for that matter). Example:
gcc -O3 -L. -o myprog myprog.c -lzzip
I want to use zzip lib, which I have in the directory it was compiled under (I can't remember if it complains about 'undefined references' or not, but I don't think it does), however when I run it it says something like:
ld: unable to open file libzzip.etc.etc... no such file or directory
How do I make the program use libraries from any path I want?
If I understand you correctly, I think you are saying that you are not having any problems getting your program to compile, but it complains when you try to run the program?
I haven't worked much with my own libraries in Linux, so this could be wrong, but I think you need to put your path to your .so into /etc/ld.so.conf, and then run ldconfig as root... Obviously, this might cause problems if you want to be able to move your .so around a lot, so it might just be good to put it in a standard lib directory like /usr/lib, or /lib.
Originally posted by deiussum
I haven't worked much with my own libraries in Linux, so this could be wrong, but I think you need to put your path to your .so into /etc/ld.so.conf, and then run ldconfig as root... Obviously, this might cause problems if you want to be able to move your .so around a lot, so it might just be good to put it in a standard lib directory like /usr/lib, or /lib. [/B]
This is what I DON'T want to do.
Originally posted by deiussum If I understand you correctly, I think you are saying that you are not having any problems getting your program to compile, but it complains when you try to run the program?
This is what I want.
I'll try what you suggested shishir. I'll get back with you soon!
Ok... I'm confused. Are you saying that I am right that you are getting no errors when compiling, but you get errors when you try to run the program? Saying, "This is what I want" makes no sense because I wouldn't think you would WANT errors at all...
this is the problem becoz the GNU linke ld, check the library file to link in l/lib and /usr/lib gnerally and the name of the shared library should be fothe form lib<name>.so.0 or lib<name>.a or similar ... the <name> specifies the name fo the libarary and the when compiling and linking you need give the name as such along with the -l option .. this how it works...
Ok Sorry for the confusion! I am bad at explaining things! =P
I have my program that uses libzzip for opening zipped files. It compiles fine when I install libzzip system wide. However I don't want to do this, I want libzzip to reside in the same folder as my application (not system wide). But when I do this, it compiles fine but won't run, and gives an error as such:
ld: unable to open libzzip.so, no such file or directory.
As I said before, for shared objects, I think you need the directory of your library in /etc/ld.so.conf, and ldconfig run. That doesn't seem desireable for what you want, though. Another option might be to get a static library version of libzzip, and link that instead (libzzip-0.a). Then that library isn't needed at runtime at all. It is compiled right into your executable code instead.
I think I've also seen some references to dynamically loading libraries, but I don't know if that would give you what you need, or how to use that. It might be worth looking into. I think the library I saw was roughly equivalent to the LoadLibrary/GetProcAddress APIs in Win32. If it was, it could be what you are looking for. Unfortunately, I don't remember the name of any of those functions, offhand.