Getting a .pro file to work for both Visual Studio 2008 and Qt Creator



  • I asked this question a month or so back and never really came up with a solution:

    The code based started with a Qt GUI Application project. The pro file was tweaked and everything compiled and ran fine in VS2008.

    An experimental Qt Quick Application was created to start prototyping a QML based UI. This ran just fine in Qt Creator.

    Then the pro files from the #1 and #2 have been merged. It runs fine in VS2008 but in Qt Creator, it cannot find the QML files.

    It is now time to start doing some testing/development on the Mac. What changes need to take place to the following pro file so that it will work in both VS2008 and Qt Creator?

    @# Add more folders to ship with the application, here
    folder_01.source = qml/SalesCenter
    folder_01.target = qml
    DEPLOYMENTFOLDERS = folder_01

    Additional import path used to resolve QML modules in Creator's code model

    QML_IMPORT_PATH =

    Avoid auto screen rotation

    #DEFINES += ORIENTATIONLOCK

    Needs to be defined for Symbian

    QT += sql
    CONFIG += debug_and_release
    DEFINES += QT_LARGEILE_SUPPORT QT_SQL_LIB _USE_32BIT_TIME_T NETWORKACCESS
    QTPLUGIN += qjpeg
    INCLUDEPATH += ./../../../../include ./GeneratedFiles .
    PRECOMPILED_HEADER = stdafx.h
    UI_DIR += ./GeneratedFiles
    RCC_DIR += ./GeneratedFiles

    CONFIG(debug, debug|release) {
    DESTDIR = ../Debug
    LIBS += -L../Debug
    OBJECTS_DIR += Debug
    MOC_DIR += ./GeneratedFiles/Debug
    INCLUDEPATH += ./GeneratedFiles/Debug
    } else {
    DESTDIR = ../Release
    LIBS += -L../Release
    OBJECTS_DIR += Release
    MOC_DIR += ./GeneratedFiles/Release
    INCLUDEPATH += ./GeneratedFiles/Release
    }

    symbian:TARGET.UID3 = 0xE46A320F

    Smart Installer package's UID

    This UID is from the protected range

    and therefore the package will fail to install if self-signed

    By default qmake uses the unprotected range value if unprotected UID is defined for the application

    and 0x2002CCCF value if protected UID is given to the application

    #symbian:DEPLOYMENT.installer_header = 0x2002CCCF

    Define QMLJSDEBUGGER to allow debugging of QML in debug builds

    (This might significantly increase build time)

    DEFINES += QMLJSDEBUGGER

    If your application uses the Qt Mobility libraries, uncomment

    the following lines and add the respective components to the

    MOBILITY variable.

    CONFIG += mobility

    MOBILITY +=

    The .cpp file which was generated for your project. Feel free to hack it.

    Please do not modify the following two lines. Required for deployment.

    include(qmlapplicationviewer/qmlapplicationviewer.pri)
    qtcAddDeployment()

    include(SalesCenter.pri)
    @



  • I have no idea about the actual problem. It's hard to debug without the complete files (what's in SalesCenter.pri and in qmlapplicationviewer/qmlapplicationviewer.pri?)

    Though, I spotted some small glitches in the project file:

    • UI_DIR and RCC_DIR should be set with "=" not, appended to with "+="n
    • There is a typo in "DEFINES += QT_LARGEILE_SUPPORT" (add an F for FILE)

    Also, you should capsulate the platform dependent portions in their own scope.



  • Wow, totally missed the existence of qmlapplicationviewer.pri. You will find that below along with the SalesCenter.pri.

    The SalesCenter.pri simply lists all the files which make up the C++ side of the application. It is a vs-addin concept, there is menu option to update the pri after adding or removing files via Visual Studio.

    I made the two corrections you pointed out and no change, VS2008 runs fine, Qt Creator comes up with a blank screen and an error message:

    file:///D:/MSDev/PhotoParata/Qt/Debug/qml/SalesCenter/main.qml: File not found

    The folders layout is the default layout that Qt Creator created for me:

    D:MSDevPhotoParataQtSalesCenter is the <solution folder> where the Qt's .pro and Visual Studio .vcproj/.sln files are found.

    All the qml files are in <solution folder>\qml\SalesCenter

    It looks like Qt Creator is putting the EXE in the wrong folder, it is placing it in <solution folder>..\Debug, where as VS2008 is placing the exe (and object files) in <solution folder>\Debug.

    Some how when running the code from with in VS2008, it knows to find the qml files in <solution folder>qmlSalesCenter, where Qt Creator is looking in <solution folder>..\Debug\qml\SalesCenter.

    The post is too long, so I will follow up in the next post with the files...



  • qmlapplicationviewer.pri
    @# checksum 0xb7ef version 0x2000a
    QT += declarative

    SOURCES += $$PWD/qmlapplicationviewer.cpp
    HEADERS += $$PWD/qmlapplicationviewer.h
    INCLUDEPATH += $$PWD

    defineTest(minQtVersion) {
    maj = $$1
    min = $$2
    patch = $$3
    isEqual(QT_MAJOR_VERSION, $$maj) {
    isEqual(QT_MINOR_VERSION, $$min) {
    isEqual(QT_PATCH_VERSION, $$patch) {
    return(true)
    }
    greaterThan(QT_PATCH_VERSION, $$patch) {
    return(true)
    }
    }
    greaterThan(QT_MINOR_VERSION, $$min) {
    return(true)
    }
    }
    return(false)
    }

    contains(DEFINES, QMLJSDEBUGGER) {
    CONFIG(debug, debug|release) {
    !minQtVersion(4, 7, 1) {
    warning()
    warning("Disabling QML debugging:")
    warning()
    warning("Debugging QML requires the qmljsdebugger library that ships with Qt Creator.")
    warning("This library requires Qt 4.7.1 or newer.")
    warning()
    DEFINES -= QMLJSDEBUGGER
    } else:isEmpty(QMLJSDEBUGGER_PATH) {
    warning()
    warning("Disabling QML debugging:")
    warning()
    warning("Debugging QML requires the qmljsdebugger library that ships with Qt Creator.")
    warning("Please specify its location on the qmake command line, eg")
    warning(" qmake -r QMLJSDEBUGGER_PATH=$CREATORDIR/share/qtcreator/qmljsdebugger")
    warning()
    DEFINES -= QMLJSDEBUGGER
    } else {
    include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
    }
    } else {
    DEFINES -= QMLJSDEBUGGER
    }
    }

    defineTest(qtcAddDeployment) {
    for(deploymentfolder, DEPLOYMENTFOLDERS) {
    item = item$${deploymentfolder}
    itemsources = $${item}.sources
    $$itemsources = $$eval($${deploymentfolder}.source)
    itempath = $${item}.path
    $$itempath= $$eval($${deploymentfolder}.target)
    export($$itemsources)
    export($$itempath)
    DEPLOYMENT += $$item
    }

    MAINPROFILEPWD = $$PWD

    symbian {
    ICON = $${TARGET}.svg
    TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
    contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -lcone
    contains(DEFINES, NETWORKACCESS):TARGET.CAPABILITY += NetworkServices
    } else:win32 {
    copyCommand =
    for(deploymentfolder, DEPLOYMENTFOLDERS) {
    source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
    source = $$replace(source, /, )
    sourcePathSegments = $$split(source, )
    target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
    target = $$replace(target, /, )
    !isEqual(source,$$target) {
    !isEmpty(copyCommand):copyCommand += &&
    copyCommand += $(COPY_DIR) "$$source" "$$target"
    }
    }
    !isEmpty(copyCommand) {
    copyCommand = echo Copying application data... && $$copyCommand
    copydeploymentfolders.commands = $$copyCommand
    first.depends = $(first) copydeploymentfolders
    export(first.depends)
    export(copydeploymentfolders.commands)
    QMAKE_EXTRA_TARGETS += first copydeploymentfolders
    }
    } else:unix {
    maemo5 {
    installPrefix = /opt/usr
    desktopfile.path = /usr/share/applications/hildon
    } else {
    installPrefix = /usr
    desktopfile.path = /usr/share/applications
    copyCommand =
    for(deploymentfolder, DEPLOYMENTFOLDERS) {
    source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
    source = $$replace(source, , /)
    macx {
    target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
    } else {
    target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
    }
    target = $$replace(target, , /)
    sourcePathSegments = $$split(source, /)
    targetFullPath = $$target/$$last(sourcePathSegments)
    !isEqual(source,$$targetFullPath) {
    !isEmpty(copyCommand):copyCommand += &&
    copyCommand += $(MKDIR) "$$target"
    copyCommand += && $(COPY_DIR) "$$source" "$$target"
    }
    }
    !isEmpty(copyCommand) {
    copyCommand = echo Copying application data... && $$copyCommand
    copydeploymentfolders.commands = $$copyCommand
    first.depends = $(first) copydeploymentfolders
    export(first.depends)
    export(copydeploymentfolders.commands)
    QMAKE_EXTRA_TARGETS += first copydeploymentfolders
    }
    }
    for(deploymentfolder, DEPLOYMENTFOLDERS) {
    item = item$${deploymentfolder}
    itemfiles = $${item}.files
    $$itemfiles = $$eval($${deploymentfolder}.source)
    itempath = $${item}.path
    $$itempath = $${installPrefix}/share/$${TARGET}/$$eval($${deploymentfolder}.target)
    export($$itemfiles)
    export($$itempath)
    INSTALLS += $$item
    }
    icon.files = $${TARGET}.png
    icon.path = /usr/share/icons/hicolor/64x64/apps
    desktopfile.files = $${TARGET}.desktop
    target.path = $${installPrefix}/bin
    export(icon.files)
    export(icon.path)
    export(desktopfile.files)
    export(desktopfile.path)
    export(target.path)
    INSTALLS += desktopfile icon target
    }

    export (ICON)
    export (INSTALLS)
    export (DEPLOYMENT)
    export (TARGET.EPOCHEAPSIZE)
    export (TARGET.CAPABILITY)
    export (LIBS)
    export (QMAKE_EXTRA_TARGETS)
    }
    @

    SalesCenter.pri
    @# ----------------------------------------------------

    This file is generated by the Qt Visual Studio Add-in.

    ------------------------------------------------------

    HEADERS +=
    ./DBManager.h
    ./FavoriteSqlModel.h
    ./stdafx.h
    ./StationManager.h
    ./SystemSettings.h

    SOURCES +=
    ./DBManager.cpp
    ./FavoriteSqlModel.cpp
    ./main.cpp
    ./stdafx.cpp
    ./StationManager.cpp
    ./SystemSettings.cpp

    OTHER_FILES +=
    @



  • [quote author="scarleton" date="1296431511"]Wow, totally missed the existence of qmlapplicationviewer.pri. You will find that below along with the SalesCenter.pri.

    The SalesCenter.pri simply lists all the files which make up the C++ side of the application. It is a vs-addin concept, there is menu option to update the pri after adding or removing files via Visual Studio.

    I made the two corrections you pointed out and no change, VS2008 runs fine, Qt Creator comes up with a blank screen and an error message:

    file:///D:/MSDev/PhotoParata/Qt/Debug/qml/SalesCenter/main.qml: File not found

    The folders layout is the default layout that Qt Creator created for me:

    D:MSDevPhotoParataQtSalesCenter is the <solution folder> where the Qt's .pro and Visual Studio .vcproj/.sln files are found.

    All the qml files are in <solution folder>\qml\SalesCenter

    It looks like Qt Creator is putting the EXE in the wrong folder, it is placing it in <solution folder>..\Debug, where as VS2008 is placing the exe (and object files) in <solution folder>\Debug.

    Some how when running the code from with in VS2008, it knows to find the qml files in <solution folder>qmlSalesCenter, where Qt Creator is looking in <solution folder>..\Debug\qml\SalesCenter.

    The post is too long, so I will follow up in the next post with the files...[/quote]

    Did you to change the shadow build settings on the project view/build settings? I would guess the "wrong" debug folder is set there. The other solution would be to add a deployment step that copies all the necessary files to the right folder.



  • To the best of my knowledge I only changed to pro file. Is there some way to set the shadow build settings in the pro file? If not, it would be nice if you could.

    Sam



  • The shadow build feature is enabled in Qt Creator. It's achieved by creating the dir, change directory into that new dir and calling qmake there. This leaves the Makefile in the shadow build dir. This all is handled by Creator internally, so no tweaking by your side.

    Did you try to disable the shadow builds in Creator at all (Project view, build settings, uncheck the checkbox).



  • I will give that a try.

    What I don't understand is:

    The pro file worked fine in Qt Creator

    The pro file was changed to work in VS2008

    The pro file stopped working in Qt Creator.

    Why do I now need to go into the Qt Creator project settings to make the change, why can't the changes be made in the pro file?



  • It was the same Creator instance (same computer) or the same project dir? If not - the build settings etc. are on a project/directory base. They are not saved in the .pro file.

    It definitely works cross platform, we do it on our project here (Mac with Creator, Windows with Visual Studio, sometimes Linux with qmake on the command line).

    In such weird situations I would suggest to setup a simple hello world project, make it work on both IDEs. Add some QML stuff afterwards, make it work on both IDEs again and the adapt that settings to your actual project. This way you get the distorting stuff out of the way and you can focus on the project configuration.



  • I disabled the shadow build and nothing changed, it still builds to the wrong folder:

    D:\MSDev\PhotoParata\Qt\Debug,

    rather than where VS2005 builds it:

    D:\MSDev\PhotoParata\Qt\SalesCenter\debug

    I still get a white screen and the error message:

    @file:///D:/MSDev/PhotoParata/Qt/Debug/qml/SalesCenter/main.qml: File not found@

    There is some change that needs to happen in the pro file, but I don't have a clue as to what it might be. I am hoping a Nokia developer will read this post and chime in with a solution:)



  • [quote author="Volker" date="1296483306"]In such weird situations I would suggest to setup a simple hello world project, make it work on both IDEs. Add some QML stuff afterwards, make it work on both IDEs again and the adapt that settings to your actual project. This way you get the distorting stuff out of the way and you can focus on the project configuration.[/quote]

    This is what I really would do now...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.