Home > OS >  The MakeFile library link problem
The MakeFile library link problem

Time:09-26

The following problems when writing a Makefile lately,

A library liba. So libb. So the libc. So in my project directory, such as/home/wb/code/project/lib

Liba. So dependent on libb. So and libc. So

Personal code only liba. So the code in my Makefile to specify the
- Wl - rpath=/home/wb/code/project/lib - la

So there is no question of compilation, but running will be prompted to find libb. So...

LDD with go to the executable file, executable files can also be found in the lib list does need libb. So and libc. So, but behind that can't find the library files

I also use - Wl - rpath=/home/wb/code/project/lib - lb - lc to try
At the same time use the -l specifies the file location, but the error

Please have a great god can solve,


Now I have to put the libb. So the libc. So copy to the system directory for subsequent development,

CodePudding user response:

Dynamic link library is to be followed to run the program, and can't find library generates static directly connected to compile the results

CodePudding user response:

reference 1st floor xuweiwei1860 response:
dynamic link library is to be followed to run the program, and can't find libraries are generated inside the result of the static directly connected to compile


Still need to use dynamic link, but we hope to run the program for libraries to find me the specified file directory, rather than the system directory, at the same time, also do not want to change the LD_LIBRARY_PATH values, because want to make this project a a moveable, even if the copies to other computers, compiled directly, you can run, I don't want to make redundant configuration,

CodePudding user response:

reference 1st floor xuweiwei1860 response:
dynamic link library is to be followed to run the program, and can't find libraries are generated inside the result of the static directly connected to compile

Sometimes it's really hard to use of dynamic link library suddenly don't why I can't find it,,,,

CodePudding user response:

The mechanism of dynamic link library, need you to specify the location of the dynamic libraries at compile time to complete the compilation, the program executes, the system library directory to find the dynamic library, such as ubuntu under dynamic library compiled path shall be added to the/etc/ld. So. The conf file, reoccupy ldconfig command (or reset) the effective path

CodePudding user response:

Links in the rpath is a good method, not met, the original poster can not confirm whether spelling mistakes

 
- Wl - rpath=/home/wb/code/project/lib
^ to check whether there is a space here?

CodePudding user response:


- Wl - rpath=/home/wb/code/project/lib
^ to check whether there is a space here?
  • Related