PDA

View Full Version : Multi target projects



Radek
25th October 2014, 08:46
I have a project wihich should build a shared library and a test program for it. I have created a project:


TEMPLATE = subdirs

SUBDIRS += \
library \
exe

exe.depends = library

a library project:


TEMPLATE = lib
TARGET = mylib
QT = core
QMAKE_CXXFLAGS += -std=c++11
INCLUDEPATH += hpp
DEPENDPATH += hpp

HEADERS += \
...

SOURCES += \
...

and the test program project exe:


TEMPLATE = app
QT = core
TARGET = myapp
QMAKE_CXXFLAGS += -std=c++11
INCLUDEPATH += ../library/hpp hpp
DEPENDPATH += ../library/hpp hpp
LIBS += -L../library -lmylib

HEADERS += \
...

SOURCES += \
...

This seems to compile. Headers, both in library/hpp and exe/hpp, seem to be found, both libmylib.so and myapp are sitting in their folders, no errors or warnings are reported. But it will not run. IMO, the problem is in the library location.of libmylib.so, is not found at runtime. The problem is that there will be two libmylib.so in the end: one in debug build, one in release build. That's why I do not want to play with LD_LIBRARY_PATH. Is there some option which would say the executable loader where is libmylib.so in the case of debug build and where it is in the case in release build? And a question in advance:

This project is made as a preparation for dynamic linking shared objects using QLibrary. Which is the best (temporary, before the .so is placed on the libpath) way of specifying the correct path for libmylib.so?

Radek
25th October 2014, 15:07
Okay, answering myself. The problem didn't consist in the libpath, it consisted in the executable. The "run" and "debug" commands did not know, which target they should run. They searched an executable in the root project directory, where was no executable. With a multi target project like this, you need to open the "Project" tab, select "Run" and set the right executable. Both run and debug will work.