[Solved with alternative solution] Add subfolders with libraries and includes depending on processor bitness
-
Hi all.
I'm developing a medium Qt project. It has already a good bunch of files .h, .cpp, and .ui. All files are in same folder, and it's OK for me by now.
My environment is Ubuntu 12.04 LTS, with Qt Creator 2.5.2, 64 bits.
Now, I need to add some files to the project; those files differs on the target processor bitness.
These files for x64 are:
camboardnano.L64.pap
camboardnanoproc.L64.ppp
libpmdaccess2.so
pmddatadescription.h
pmdsdk2.h
pmdsdk2common.hFiles for x86 are:
camboardnano.L32.pap
camboardnanoproc.L32.ppp
libpmdaccess2.so
pmddatadescription.h
pmdsdk2.h
pmdsdk2common.hI'd like to add them in separate subfolders of the project's one: PMDSDK2_L64 and PMDSDK2_L32, and link them depending of the current processor.
Googling or reading Qt's docu haven't suggested me any (simple) solution for this. How can I achieve it? What would be the best way to achieve this? (the idea is that if I copy this project to an 32 bits environment, I will be able to compile there with the right files previously added)
Thanks in advance!
-
Hi,
The simplest I can think of is:
@
CONFIG(x86, x86|x86_64) {
#32 bit stuff
}CONFIG(x86_64, x86|x86_64) {
#64 bit stuff
}
@CONFIG += "The arch you want to build" when you run qmake. You can add that to QtCreators build pan in Build Steps
Hope it helps
-
Hmmmm...
I will have to consider your aportation.
What I have got so far by now is that my .pro file of the project must have (for a x64 fixed environment):
@#Header and library in subfolders. $$PWD points to project folder
LIBS += -L$$PWD/PMDSDK2_L64/ -lpmdaccess2
INCLUDEPATH += $$PWD/PMDSDK2_L64
DEPENDPATH += $$PWD/PMDSDK2_L64
HEADERS += pmdsdk2.h@Now I will try to merge this with your apportation. Thanks, SGaist.
-
[quote author="SGaist" date="1372421312"]Hi,
The simplest I can think of is:
@
CONFIG(x86, x86|x86_64) {
#32 bit stuff
}CONFIG(x86_64, x86|x86_64) {
#64 bit stuff
}
@CONFIG += "The arch you want to build" when you run qmake. You can add that to QtCreators build pan in Build Steps
Hope it helps[/quote]
This doesn't work. Perhaps that works in Windows, but it does'nt under LInux.
This in .pro
@CONFIG(x86, x86|x86_64)
{
#32 bit stuff
message("Building 32 bits")
}CONFIG(x86_64, x86|x86_64)
{
#64 bit stuff
message("Building 64 bits")
}@will output:
@Project MESSAGE: Building 32 bits
Project MESSAGE: Building 64 bits@I'm reading about CONFIG variables, specially $$QMAKE_HOST.arch, but
@message($$QMAKE_HOST.arch)
message(QMAKE_HOST.arch)
message($$QMAKE_HOST)
(same with QMAKE_TARGET) @
prints nothing. -
QMAKE_HOST.arch seems to be broken on *nix (also observed it on OS X)
You need to either run qmake with CONFIG=x86 to make the selection (until there's a fix for QMAKE_HOST.arch)
@qmake CONFIG=x86@
-
The final solution I've applied is manually activate or deactivate libraries and folders depending of some manual variable defined in .pro file
(look this post of mine: "[Solved] .pro file questions (custom variables, mkspecs and contains())":http://qt-project.org/forums/viewthread/29381/).So finally I will have something like this in my .pro file, setting manually the desired bitness:
@
PROCBITS = "64"
message($$PROCBITS)
contains( PROCBITS , 64 ){
message("Including 64 bits libraries")
LIBS += -L$$PWD/PMDSDK2_L64/ -lpmdaccess2
INCLUDEPATH += $$PWD/PMDSDK2_L64
DEPENDPATH += $$PWD/PMDSDK2_L64
HEADERS += pmdsdk2.h
}
contains( PROCBITS , 32 ){
message("Including 32 bits libraries")
LIBS += -L$$PWD/PMDSDK2_L32/ -lpmdaccess2
INCLUDEPATH += $$PWD/PMDSDK2_L32
DEPENDPATH += $$PWD/PMDSDK2_L32
HEADERS += pmdsdk2.h
}
@and the corresponding 64 bits libraries are in subfolders PMDSDK2_L32 and PMDSDK2_L64 in my project folder.