jkv
3rd September 2009, 01:41
Hi,
Not sure if this really Qt specific problem, but here goes... :)
I have a Qt gui-project which directory structure after successful build should look like follows (only relevant stuff to my problem, below)
LibBap/ // Links with muparser
LibBap.pro
<sources>
Bap/ // Links with LibBap
Bap.pro
<sources>
BapPlugin/ // Links with LibBap
BapPlugin.pro
<sources>
Extra/
muparser/
muparser.pro
<sources>
bin/
Bap
lib/
libLibBap.so
libmuparser.so
libBapPlugin.so
Build steps before error:
1) libmuparser.so
- built only if system doesn't have this already installed
- compiles/links fine
- moved to bin/lib
2) libLibBap.so
- links with libmuparser.so (either the one in bin/lib or system /usr/lib)
- compiles/links fine
- moved to to bin/lib/
3) Bap
- main executable
- links directly with libLibBap.so (and indirectly on libmuparser.so)
- compiles ok, but linker gives error:
g++ -o ../bin/Bap <objects> -L/usr/lib64/qt4 -L../bin/lib -lBapLib <bunch of -llibs> /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libmuparser.so.1, needed by ../bin/lib/libBapLib.so, not found (try using -rpath or -rpath-link)
../bin/lib/libBapLib.so: undefined reference to `mupGetErrorMsg(void*)'
../bin/lib/libBapLib.so: undefined reference to `mupCreate()'
../bin/lib/libBapLib.so: undefined reference to `mupRelease(void*)'
../bin/lib/libBapLib.so: undefined reference to `mupError(void*)'
../bin/lib/libBapLib.so: undefined reference to `mupEval(void*)'
../bin/lib/libBapLib.so: undefined reference to `mupSetExpr(void*, char const*)'
../bin/lib/libBapLib.so: undefined reference to `mupDefineVar(void*, char const*, double*)'
../bin/lib/libBapLib.so: undefined reference to `mupSetVarFactory(void*, double* (*)(char const*, void*), void*)'
So from above it seems to me that linker ignores search path (-L../bin/lib) as it resolves dependencies (libmuparser.so) of libraries linked with -l flag (libBapLib.so).
If I do 'LD_LIBRARY_PATH=../bin/lib make' in Bap/ OR install muparser in /bin/lib instead there is no error. But neither of these is suitable solution in long term.
I tried -rpath and -rpath-link in qmake LIBS variable as the linker suggests but no success. I also tried create_prl and link_prl for BapLib.pro and Bap.pro but no effect. But maybe there is some linker flag or qmake variable that sorts these kind of problems ? I hope there is some obvious thing I missed...
What can I do to let linker know of the second library ?
Thanks!
Not sure if this really Qt specific problem, but here goes... :)
I have a Qt gui-project which directory structure after successful build should look like follows (only relevant stuff to my problem, below)
LibBap/ // Links with muparser
LibBap.pro
<sources>
Bap/ // Links with LibBap
Bap.pro
<sources>
BapPlugin/ // Links with LibBap
BapPlugin.pro
<sources>
Extra/
muparser/
muparser.pro
<sources>
bin/
Bap
lib/
libLibBap.so
libmuparser.so
libBapPlugin.so
Build steps before error:
1) libmuparser.so
- built only if system doesn't have this already installed
- compiles/links fine
- moved to bin/lib
2) libLibBap.so
- links with libmuparser.so (either the one in bin/lib or system /usr/lib)
- compiles/links fine
- moved to to bin/lib/
3) Bap
- main executable
- links directly with libLibBap.so (and indirectly on libmuparser.so)
- compiles ok, but linker gives error:
g++ -o ../bin/Bap <objects> -L/usr/lib64/qt4 -L../bin/lib -lBapLib <bunch of -llibs> /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libmuparser.so.1, needed by ../bin/lib/libBapLib.so, not found (try using -rpath or -rpath-link)
../bin/lib/libBapLib.so: undefined reference to `mupGetErrorMsg(void*)'
../bin/lib/libBapLib.so: undefined reference to `mupCreate()'
../bin/lib/libBapLib.so: undefined reference to `mupRelease(void*)'
../bin/lib/libBapLib.so: undefined reference to `mupError(void*)'
../bin/lib/libBapLib.so: undefined reference to `mupEval(void*)'
../bin/lib/libBapLib.so: undefined reference to `mupSetExpr(void*, char const*)'
../bin/lib/libBapLib.so: undefined reference to `mupDefineVar(void*, char const*, double*)'
../bin/lib/libBapLib.so: undefined reference to `mupSetVarFactory(void*, double* (*)(char const*, void*), void*)'
So from above it seems to me that linker ignores search path (-L../bin/lib) as it resolves dependencies (libmuparser.so) of libraries linked with -l flag (libBapLib.so).
If I do 'LD_LIBRARY_PATH=../bin/lib make' in Bap/ OR install muparser in /bin/lib instead there is no error. But neither of these is suitable solution in long term.
I tried -rpath and -rpath-link in qmake LIBS variable as the linker suggests but no success. I also tried create_prl and link_prl for BapLib.pro and Bap.pro but no effect. But maybe there is some linker flag or qmake variable that sorts these kind of problems ? I hope there is some obvious thing I missed...
What can I do to let linker know of the second library ?
Thanks!