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

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

问题描述

也许是一个非常简单的问题:

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以摆脱-m32在OPTFLAG,但再次当程序编译时,我仍然看到-m32显示和二进制仍然是32位。

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

这个错误意味着有一个选项 -march = i686

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.

如果你不能删除它(更努力!),那么在makefile中的$ c>在命令行后添加 -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位机器上编译64位的C ++程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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