Qt World Summit: Submit your Presentation

Stupid question: how to add reference in .pro file to static lib compiled from source

  • Hi,

    As you can guess from the title of this post I'm a newbie to Qt.
    I have a simple problem which I do not know how to solve:
    I want to use the qjson library. I downloaded the source code in PRJOECTS/qjson (where PROJECTS is the root directory
    of my working projects, let's say "c:\work\cuteprojs" or something like it, I put all my qt projects in there)
    I have successfully compiled qjson for harmattan and desktop; After the build I have 2 directories:
    PROJECTS/qjson-build-desktop & PROJECTS/qjson-build-harmattan

    Now I have another project, TestQJson, where I want to use the static lib generated from the qjson projects.
    Inside PROJECTS/TestQJson/TestQJson.pro file I add the following:

    1. INCLUDEPATH += ../qjson/src
    2. LIBS += -lqjson
    3. LIBS += -L../qjson-build-harmattan/lib/

    For line 1) everything is clear, TestQJSon correctly finds the necessary .h files from qjson.
    Now in line 2) I tell QMAKE (or whatever trolls refer to the build system/framework/makefile/etc) that TestQJson will link to the static qjson library; and in line 3) I tell it where to find this library. It compiles and everything is ok.

    HOWEVER, if now I want to build for desktop target I need to modify line 3) like this:
    3) LIBS += -L../qjson-build-desktop/lib/

    Is there a more elegant solution to this problem?
    (Please ignore the qjson reference, e.g. the issue is not related to the qjson project, it's related to any other project that builds as a static lib)

    Thanks & regards,

  • Have at look at "scopes":http://doc.qt.nokia.com/latest/qmake-advanced-usage.html#scopes in the qmake manual.

Log in to reply