Split project into shared libs - linking issue.
Hello
I have problem to set correct build settings to create and link shared libs.
My solution (session) structure:
- Faktur (main app)
- MainWindow (lib)
- MenuGlowne (lib)
- PrintThread (lib)
- QueryThread (lib)
For each project I defined dependencies. All projects has the same build directory. Finally all libs are being build but when main app is being created then error appear:
Quote:
/usr/bin/ld: warning: libmenuglownelib.so.1, needed by ./libmainwindowlib.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libprintthreadlib.so.1, needed by ./libmainwindowlib.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libquerythreadlib.so.1, needed by ./libmainwindowlib.so, not found (try using -rpath or -rpath-link)
I had defined lib's folders and names for each project:
- MainApp
Quote:
QT += core gui sql
TARGET = Faktura
TEMPLATE = app
SOURCES += \
main.cpp
LIBS += -L"."
LIBS += -lmainwindowlib
INCLUDEPATH += ../MainWindow
-MainWindow
Quote:
QT += core gui sql
TARGET = mainwindowlib
TEMPLATE = lib
DEFINES += MAINWINDOWLIB_LIBRARY
HEADERS += \
mainwindow.h \
mainwindowlib_global.h \
timer.h
SOURCES += \
mainwindow.cpp \
timer.cpp
FORMS += \
mainwindow.ui
INCLUDEPATH += ../MenuGlowne \
../FakturaVAT \
../PrintThread
../QueryThread
debug:LIBS += -L"."
release:LIBS += -L"."
LIBS += -lmenuglownelib \
-lprintthreadlib \
-lquerythreadlib
-PrintThread
Quote:
QT += core gui sql
TARGET = printthreadlib
TEMPLATE = lib
DEFINES += PRINTTHREADLIB_LIBRARY
HEADERS += \
printthread.h \
printthreadlib_global.h
SOURCES += \
printthread.cpp
Basicly on windows I had compiled project. Problem has appeared on linux. Somehow linker is not linking shared libs into other shared lib.
What I'm doing wrong?
Re: Split project into shared libs - linking issue.
Where do those three files mentioned by the warnings exist? Are you using shadow builds?
Re: Split project into shared libs - linking issue.
All files exist in the same folder. All projects has the same build folder.
What does mean "shadow builds"? What is it?
Re: Split project into shared libs - linking issue.
"Same folder" meaning which one? A shadow build is also called "out of source" build -- when the main compilation directory is different from the source directory.
Re: Split project into shared libs - linking issue.
Faktur project is in folder: /home/user/workspace/qt4/FakturSession/Faktur/
MainWindow: /home/user/workspace/qt4/FakturSession/MainWindow/
PrintThread: /home/user/workspace/qt4/FakturSession/PrintThread/
All projects has the same build destination: /home/user/workspace/qt4/FakturSession/Faktur-build-desktop/
Re: Split project into shared libs - linking issue.
In that case you need to pass "-L../Faktur-build-desktop" instead of "-L."
Re: Split project into shared libs - linking issue.
I have passed "-L../Faktur-build-desktop" into projects where lib folder is being defined and still the same issue. All libs are created but on last step, when application is being created, those errors appears.
Re: Split project into shared libs - linking issue.
The build system can't find the libraries. That means it hasn't been told where to look for them. Since you're able to locate them, add their location to the project file, do a 'make clean', qmake and rebuild everything. Or, if you want them all in one place, arrange for the build system to deliver them to that location with the 'install' object.
If there are still problems, examine the build lines generated during make, and ensure that both the compiler and linker are looking in the proper locations and sending output to the proper locations. If not, revisit the project file, 'make clean', qmake and rebuild, again. Note whether your changes have taken place.
Re: Split project into shared libs - linking issue.
It's working now. Thank you for your help.
Re: Split project into shared libs - linking issue.
I have one more question regarding this subject.
Some of projects (compiled as libs) contains folders with .png files. Can I have one global folder with icons (.png) for all of those projects? What is best solution in this situation? How to correct store and define those files as resources?