检查我使用的是 32 位还是 64 位 Linux 的最佳方法是什么? [英] What is the best way to check if I have a 32-bit or a 64-bit Linux?

查看:23
本文介绍了检查我使用的是 32 位还是 64 位 Linux 的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有 32 位或 64 位 Linux,我必须检查 CMake 脚本才能知道如何构建 C++ 程序.哪个命令是最佳选择:

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 :

  • getconf LONG_BIT
  • 拱门
  • uname -m

推荐答案

使用 CMake 的一种可能方法是检查 CMAKE_SIZEOF_VOID_P 变量:

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()

这篇关于检查我使用的是 32 位还是 64 位 Linux 的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆