Unsolved How does QMake process .prl files?
-
Hello,
I need to pass certain #define from library to main application. As far as I understand, it can be achieved with .prl files.
I've created simple subdirs project to test it:This is main project file:
TEMPLATE = subdirs SUBDIRS += \ app \ lib app.depends = lib
This is library project file:
QT -= gui TARGET = lib TEMPLATE = lib # Added create_prl option CONFIG += staticlib create_prl # This is the define I want to pass to main application PRL_EXPORT_DEFINES += TEST_PRL_DEFINE SOURCES += lib.cpp HEADERS += lib.h
This is main application file:
QT += core QT -= gui CONFIG += c++11 TARGET = app # Added link_prl option CONFIG += console link_prl CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../lib/release/ -llib else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../lib/debug/ -llib else:unix: LIBS += -L$$OUT_PWD/../lib/ -llib INCLUDEPATH += $$PWD/../lib DEPENDPATH += $$PWD/../lib win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../lib/release/liblib.a else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../lib/debug/liblib.a else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../lib/release/lib.lib else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../lib/debug/lib.lib else:unix: PRE_TARGETDEPS += $$OUT_PWD/../lib/liblib.a
However, when I build the project (in Qt Creator, if that matters), no #define seems to be passed to main application except the standard ones:
cd lib\ && ( if not exist Makefile C:\Qt\5.4\mingw491_32\bin\qmake.exe C:\Qt\projects\test_prl\lib\lib.pro -spec win32-g++ CONFIG+=debug CONFIG+=qml_debug -o Makefile ) && C:/Qt/Tools/mingw491_32/bin/mingw32-make -f Makefile mingw32-make[1]: Entering directory 'C:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/lib' C:/Qt/Tools/mingw491_32/bin/mingw32-make -f Makefile.Debug mingw32-make[2]: Entering directory 'C:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/lib' # Here you can see that TEST_PRL_DEFINE is added to defines of library project g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DTEST_PRL_DEFINE -DUNICODE -DQT_QML_DEBUG -DQT_CORE_LIB -I"..\..\test_prl\lib" -I"." -I"..\..\..\5.4\mingw491_32\include" -I"..\..\..\5.4\mingw491_32\include\QtCore" -I"debug" -I"..\..\..\5.4\mingw491_32\mkspecs\win32-g++" -o debug\lib.o ..\..\test_prl\lib\lib.cpp ar -ru debug\liblib.a debug/lib.o ar: creating debug\liblib.a mingw32-make[2]: Leaving directory 'C:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/lib' mingw32-make[1]: Leaving directory 'C:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/lib' cd app\ && ( if not exist Makefile C:\Qt\5.4\mingw491_32\bin\qmake.exe C:\Qt\projects\test_prl\app\app.pro -spec win32-g++ CONFIG+=debug CONFIG+=qml_debug -o Makefile ) && C:/Qt/Tools/mingw491_32/bin/mingw32-make -f Makefile mingw32-make[1]: Entering directory 'C:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/app' C:/Qt/Tools/mingw491_32/bin/mingw32-make -f Makefile.Debug mingw32-make[2]: Entering directory 'C:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/app' # Here no TEST_PRL_DEFINE is added to #defines of main application project g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_CORE_LIB -I"..\..\test_prl\app" -I"." -I"..\..\test_prl\lib" -I"..\..\..\5.4\mingw491_32\include" -I"..\..\..\5.4\mingw491_32\include\QtCore" -I"debug" -I"..\..\..\5.4\mingw491_32\mkspecs\win32-g++" -o debug\main.o ..\..\test_prl\app\main.cpp g++ -Wl,-subsystem,console -mthreads -o debug\app.exe debug/main.o -LC:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/app/../lib/debug/ -llib -LC:/Qt/5.4/mingw491_32/lib -lQt5Cored mingw32-make[2]: Leaving directory 'C:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/app' mingw32-make[1]: Leaving directory 'C:/Qt/projects/build-test_prl-Desktop_Qt_5_4_2_MinGW_32bit-Debug/app'
How should I use create_prl/link_prl options?
-
Hi,
Sounds surprising indeed. You should take a look at the bug report system to see if it something known. It not please consider opening a report providing a minimal compilable example showing that behavior.
-
Not sure, but I'd suggest some parenthesis. For example, where you have:
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../lib/release/ -llib else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../lib/debug/ -llib else:unix: LIBS += -L$$OUT_PWD/../lib/ -llib
That might be interpreted by qmake like:
win32 { CONFIG(release, debug|release) { LIBS += -L$$OUT_PWD/../lib/release/ -llib } else { win32 { CONFIG(debug, debug|release) { LIBS += -L$$OUT_PWD/../lib/debug/ -llib } else { unix { LIBS += -L$$OUT_PWD/../lib/ -llib } } } } }
Which is probably not what you're expecting. You probably mean something more like:
win32 { CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../lib/release/ -llib CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../lib/debug/ -llib } unix: LIBS += -L$$OUT_PWD/../lib/ -llib
Cheers.