Is there a flag or something to know if the application is the 32 or 64 bit version, building on Linux?
I found a lot of flags about the OS and Window system, but none about this.
Thanks.
Is there a flag or something to know if the application is the 32 or 64 bit version, building on Linux?
I found a lot of flags about the OS and Window system, but none about this.
Thanks.
Various 'uname' flags will tell you if the machine is 64 or 32 bit. You can also parse /proc/cpuinfo. You can check a particular executable with the 'file' utility.
SixDegrees' suggestions will tell you if the operating system is running 32- or 64-bit (uname), CPU is 64-bit capable (cpuinfo) but not what mode it is currently in, or whether an arbitrary executable is 32- or 64-bit (file).
If you want to know if your running executable is 32- or 64-bit then surely you can build the application so that it knows?
Thanks for the replies ... but my problem is different ... let me explain
With Q_WS_X11 defined I know if I'm running on a x11 environment, and make specific code for this scenario if I need. Q_OS_LINUX let me check the OS, and there are another defines to check other OS's and environments.
My problem: I need something like this flags to check if I'm running 64 or 32 bit of my software version? Or, I must start to write my own define's?
Thanks![]()
The mkspec which you are compiling for is defined as a scope when qmake gets run. So for one possible solution, you could check for that scope in your .pro file, and make any special defines for yourself. For example, when I need to add a platform specific library I add the following to my .pro file.
linux-g++-32:LIBS += -Llib/ -lmyliblin32
linux-g++-64:LIBS += -Llib/ -lmyliblin64
win32-g++:LIBS += mylibwin32.lib
The benefit of this is that it's cross platform; you don't have to rely on a platform-specific utility to give you info about the same platform. The down side is there are a lot of possible mkspecs that you'd have to handle if you plan on distributing your source.
Ideally, there'd be something already defined for you, but I haven't found anything like that yet.
nomadscarecrow (21st June 2010)
Yes ... I was thinking to play with qmake and .pro file to a conditional "include" of files with the defines...
The main idea of this is the update functionality that I'm including on my software. If 32bit, download and apply 32 patch, else ... 64 bit, the 64patch. That is the reason because to know if the application is 32 or 64 bit. A elegant way is with flags, just like I mentioned ... but ... the magic will came from the qmake and .pro files
thanks.
Assuming you are are using GCC on Linux then these predefined macros may be useful:
You can see what your GCC defines with:Qt Code:
__i386__ You're compiling for a 32-bit Intel __x86_64__ You're compiling for a 64-bit Intel __ppc__ You're compiling for a 32-bit PowerPC __ppc64__ You're compiling for a 64-bit PowerPC __LP64__ possibly an indicator of 64-bitnessTo copy to clipboard, switch view to plain text mode
You could also peruse qglobal.h for hints as to how the Qt system does it.
http://predef.sourceforge.net/ is also very useful
nomadscarecrow (16th July 2010)
By the way ... thanks for the answers ... very helpful ...![]()
Bookmarks