vir2al
vir2al

Reputation: 837

What is the best way to check if I have a 32-bit or a 64-bit Linux?

I have to check in CMake script if I have a 32-bit or a 64-bit Linux in order to know how to build a C++ program. Which command is the best choice :

Upvotes: 2

Views: 441

Answers (2)

sakra
sakra

Reputation: 65751

Using CMake one possible way is to check the CMAKE_SIZEOF_VOID_P variable:

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
    message (STATUS "Compiling for 64-bit")
endif()

Upvotes: 3

LiMar
LiMar

Reputation: 2952

I'd propose to use any two of the methods together. (or all three)

Just for the backup, and to be cross platform. Another Linux distribution can use another id strings. Or be it ... FreeBSD.

And just to add another method - check architecture of some binary. Like file /usr/bin/gcc.

Upvotes: 1

Related Questions