简体   繁体   中英

Qt project file fails to cleanly recompile in release mode on windows

We have a Windows desktop software that uses flags in project files to select client specific features for use. We have two interfaces to the external device we control with the software (a materials testing machine).

As you can see below, we use different libs (dlls) in the project depending on which client is in question.

The problem is that when I turn on Release mode in Qt Creator, there appears to be some kind of cache that does not get cleared when I switch clients in clientselection.pri. I get error messages from a wrong DLL, etc. We are using Qt 5.3 and compile with MSVC2013.

In Debug mode, we typically have no such issues, at least none that Clean All + Run qmake + Rebuild All would not fix.

Changing shadow directories between builds does not help. Whatever 'cache' there is, seems to be somewhere else.

The project structure is as follows. (On Linux, issues like this never appeared, though it has been a while the whole project was compiled on Linux.)

MainApp.pro

include (clientselection.pri)
include(clientconfiguration.pri)

clientselection.pri (not in version control so each dev can switch clients on their development PC)

CONFIG+=CLIENT1
DEFINES+=CLIENT1

clientconfiguration.pri (is in version control)

CLIENT1{
    # PRODUCT_ID shows in installer directory and installer filename and start menu
    PRODUCT_ID=Client1
    message(Client1 selected clientconfiguration.pri)
    LIBS += "c://project//lib/library1.lib"
}


CLIENT2{
    # PRODUCT_ID shows in installer directory and installer filename and start menu
    PRODUCT_ID=Client2
    message(Client2 selected clientconfiguration.pri)
    LIBS += "c://project//lib/library2.lib"
}

There is another .pri file that determines current database version, and in Release mode that may be wrong in the eventual binaries, too. (Db version is determined at compile-time since it is part of the db file name, and gets relayed to an NSIS installer too, by writing it to a text file at compile time.)

Is this a completely wrong approach for selecting, compile-time, what dll's etc to include? Is there a way to completely refresh whatever was built in the previous compilation? Or is there something else going on here I don't understand?

I've faced such situations a lot. Unfortunately Clean leaves several odd-come-shorts after itself. That's why I prefer to do next:

  • execute Clean from QtCreator,
  • delete shadow folder by hands (or add Custom Process Step as Clean Step in Project settings with some script that will clean all),
  • run qmake over current project,
  • build.

Hope this strategy helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM