PDA

View Full Version : Split project into shared libs - linking issue.



porterneon
27th May 2011, 23:29
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:

/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


QT += core gui sql
TARGET = Faktura
TEMPLATE = app

SOURCES += \
main.cpp

LIBS += -L"."
LIBS += -lmainwindowlib
INCLUDEPATH += ../MainWindow


-MainWindow

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

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?

wysota
28th May 2011, 09:35
Where do those three files mentioned by the warnings exist? Are you using shadow builds?

porterneon
28th May 2011, 11:34
All files exist in the same folder. All projects has the same build folder.
What does mean "shadow builds"? What is it?

wysota
28th May 2011, 18:21
"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.

porterneon
28th May 2011, 23:17
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/

wysota
29th May 2011, 10:25
In that case you need to pass "-L../Faktur-build-desktop" instead of "-L."

porterneon
29th May 2011, 16:37
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.

SixDegrees
29th May 2011, 16:52
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.

porterneon
29th May 2011, 20:14
It's working now. Thank you for your help.

porterneon
30th May 2011, 15:15
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?