Linking libraries during build vs. install
-
Hello all. I have a problem regarding linking of shared libraries (I'll refer to them as .so files since I'm on linux).
Let's say I have project A and project B. Project A builds as an executable file and project B builds as a .soMy project tree looks like this:
-
Root
-
- A
-
- B
And this is also what it looks like in my build directory.
These projects installs to /usr/bin and /usr/lib respectively.Now, how do I go about to make it so that I can link to the installed version of project B (i.e. /usr/lib/B.so) when I compile project A?
The chain of operations look like this: build B, build A, install B, install A.
But if I declare LIBS += -L/usr/lib -lB in project A, it will look for the installed library, which isn't there during compile.Should I declare something like LIBS += -L<buildDirectory>/lib -L/usr/lib -lB?
I'm sorry if this is too incoherent, but I hope someone will understand my problem!
-
-
Hi,
If you install B after compiling A you have to link A to the B library in the build directory simply because B is not yet installed. And you'd better do this anyway, since if you change B and want to relink A to B, it would link to the installed and not newly built B.
To sum up:
@LIBS += -L<buildDirectory>/lib -lB@
Otherwise you have to build B, install B, build A, install A