views:

45

answers:

2

Hi all!

I'm new to Qt Creator and I have several questions regarding multiple build configurations. A side note: I have the QtCreator 1.3.1 installed on my Linux machine.

I need to have two configurations in my Qt Creator project. The thing is that these aren't simply debug and release but are based on the target architecture - x86 or x64. I came across http://stackoverflow.com/questions/2259192/building-multiple-targets-in-qt-qmake and from that I went trying something like:

Conf_x86 { TARGET = MyApp_x86 }

Conf_x64 { TARGET = MyApp_x64 }

This way however I don't seems to be able to use the Qt Creator IDE to build each of these separately (Build All, Rebuild All, etc. options from the IDE menu). Is there a way to achieve this - may be even show Conf_x86 and Conf_x64 as new build configurations in Qt Creator? One other thing the Qt I have is 64 bit so by default the target built using Qt Creator IDE will also be 64 bit. I noticed that the effective qmake call in the build step includes the following option '-spec linux-g++-64'. I also noticed that should I add '-spec linux-g++-32' in 'Additional arguments' it would override '-spec linux-g++-64' and the resulting target will be 32 bit. How can I achieve this by simply editing the contents of the .pro file? I saw that all these changes are initially saved in the .pro.user file but this doesn't suit me at all. I need to be able to make these configurations from the .pro file if possible. Any help will be appreciated.

10x in advance!

+1  A: 

You can use Project Settings panel to add your own build configurations. You can set what make spec for each config there. Once you create a new build config, you can use it in pro file by using the CONFIG control:

CONFIG(Conf_x86) {
# do something
}
CONFIG(Conf_x64) {
# do some other thing
}
Stephen Chu
10x for the answer. Still, I need a way to define the configurations in the .pro file if possible. As far as I know any custom configurations are stored in the the .pro.user file which I don't want to rely on. About '-spec ...' is there a way to add it as part of .pro file definitions, in that case what is the key word/section (like CONFIG, LIBS, INCLUDE, etc.)?
A: 

Hi Stephen,

I have defined Conf_x86 and Conf_x64 in the Project Settings panel and I updated my .pro sections teh way you suggested but when building it seems Qt does not recognize these as valid. For example:

CONFIG(Conf_x86) {
     OBJECTS_DIR = build/Conf_x86
}

should set the output folder for the .o files (object files) to '[My project root]/build/Conf_x86' but it fails to do so - all objects files are created in the project root folder itself. What might be wrong?

10x in advance!