How do i configure g++ to look into particular directory to search library fles?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
How do i configure g++ to look into particular directory to search library fles?
Hi.. I dont have permission to install on the disk. My program needs to link to mysql DB. I copied the Mysql.h and rest headerrs to local folder and ran the program. While executing, the program throws an error sayin
./a.out: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory.
I tried setting the LD_LIBRARY_PATH variable, but dint help. please help me how to go about it.
thanks in advance.
-llibrary
-l library
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.
The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.
The directories searched include several standard system directories plus any that you specify with -L.
Normally the files found this way are library files---archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -l option and specifying a file name is that -l surrounds library with lib and .a and searches several directories.
Code:
-Ldir
Add directory dir to the list of directories to be searched for -l.
The environment variable is LD_LIBRARY_PATH. ld is the dynamic linkers, which resolves libraries at runtime whereas the compiler only needs them to link the final executable. You can compile an executable statically (with the -static flag) assuming all required libraries exist statically on the disk (as .a files, not .so files). This was, the program will have no external library dependencies at a cost of a (potentially much) larger binary.
You will need the static library, which is usually supplied in the -devel package version. Actually, the devel versions of dependencies is usually needed when compiling from source.any way. The static library versions have .a extensions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.