如何在 64 位机器上将 C++ 程序编译为 64 位? [英] How to compile a C++ program as 64-bit on 64-bit machine?

查看:68
本文介绍了如何在 64 位机器上将 C++ 程序编译为 64 位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许是一个非常微不足道的问题:

Perhaps a very trivial question:

我需要将程序编译为 64 位(之前编写的 makefile 将其编译为 32 位).

I need to compile a program as 64-bit (earlier makefile written to compile it as 32-bit).

我看到选项 -m32 出现在每个文件编译的命令行参数中.所以,我修改了 makefile 以去掉 OPTFLAG 中的 -m32 ,但是当程序编译时,我仍然看到 -m32 出现并且二进制文件仍然是 32 位的.这个 m32 也来自其他地方吗?

I saw the option -m32 appearing in command line parameters with each file compilation. So, I modified the makefile to get rid of -m32 in OPTFLAG , but again when the program compiles, I still see -m32 showing up and binaries are still 32-bit. Does this m32 come from somewhere else as well?

推荐答案

-m32 只能来自你的 makefile 中的某个地方,你必须追踪它(使用递归 grep)并删除它.

-m32 can only be coming from somewhere in your makefiles, you'll have to track it down (use a recursive grep) and remove it.

当我能够强制使用 -m64 时,我得到您选择的 CPU 不支持 x86-64 指令集".有任何线索吗?.uname -a 给出 x86_64

When I am able to force -m64, I get "CPU you selected does not support x86-64 instruction set".Any clues?. uname -a gives x86_64

那个错误意味着在 makefile 中有一个类似 -march=i686 的选项,它对 64 位编译无效,也尝试删除它.

That error means there is an option like -march=i686 in the makefiles, which is not valid for 64-bit compilation, try removing that too.

如果你不能删除它(再努力一点!)然后在命令行上添加 -march=x86-64 将指定一个通用的 64 位 CPU 类型.

If you can't remove it (try harder!) then adding -march=x86-64 after it on the command line will specify a generic 64-bit CPU type.

这篇关于如何在 64 位机器上将 C++ 程序编译为 64 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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