PDA

View Full Version : project file for 64 and 32 bit under linux



harakiri
19th July 2010, 14:17
hi everyone,

i have two separate libraries for 32 bit and 64 bit. now i want to check in the project file, if the system is a 32 oder 64 bit system in order to use the correct library.

i am using ubuntu 10.04, Qt version 4.6.2 and i have the following part in my .pro file:


if(getconf LONG_BIT == 64) { #64 bit libs
INCLUDEPATH += x_i
LIBS += -L../x
}
else { #32 bit libs
INCLUDEPATH += y_i
LIBS += -L../y
}


"getconf LONG_BIT == 64" does not seem to work, is there a better way to solve this or is there something wrong with this line?

Lykurg
19th July 2010, 17:25
I am not 100% sure, but I guess you have to wrap your getconf command inside the system function. Something like
if( system(getconf LONG_BIT) == 64) {

Lykurg
19th July 2010, 17:29
... or you can use the mkspecs
linux-g++-32
{}
linux-g++-64
{}

harakiri
19th July 2010, 17:48
I am not 100% sure, but I guess you have to wrap your getconf command inside the system function. Something like
if( system(getconf LONG_BIT) == 64) {

that did not work, about the mkspecs: i can not compile any files, i have to include either the 64 bit or the 32 bit libraries. or what did you mean with the mkspecs?

Lykurg
19th July 2010, 20:01
Ok, I read the docs for you:

BITSIZE = $$system(getconf LONG_BIT)
if (contains(BITSIZE, 64)) {
message($$BITSIZE)
}
if (contains(BITSIZE, 32)) {
message($$BITSIZE)
}

linux-g++ {
message(On Linux)
}
macx-g++ {
message(On Mac)
}
for
qmake -spec macx-g++ test.pro it outputs
Project MESSAGE: 64
Project MESSAGE: On Mac