如何使用 Eclipse 编译 32 位 [英] How to compile for 32bit with Eclipse

查看:34
本文介绍了如何使用 Eclipse 编译 32 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在我的 64 位 Ubuntu Pc 上用 C++ 编写一个小程序.默认情况下,eclipse 为 64 位体系结构编译程序.由于我想在仍然是 32 位的服务器上使用我的小程序,因此我需要能够为 32 位编译我的程序.我怎么能在日食中做到这一点?我一直在摆弄设置,但没有任何效果...

I'm currently writing a little program in c++ on my 64bit Ubuntu Pc. By default eclipse compiles the program for a 64bit architecture. Since I want to use my little program on my server which is still 32bit, I need to be able to compile my program for 32bit. How could can I do that in eclipse? I've been fiddling for a while with the settings but nothing worked...

干杯

推荐答案

经过大量搜索和尝试后,我自己找到了答案.如果您碰巧遇到同样的问题,这是一个有效的解决方案.为此,必须安装以下软件包:

I found the answer myself, after lots of searching and trying things out. This is a solution that works if you happen to have the same problem. For this to work the following packages have to be installed:

  • gcc/g++ 和 multilib

  • gcc/g++ with multilib

ia32-libs

然后右键单击您的项目,然后选择属性".转到C/C++ Build"并选择设置".在GCC/G++ Compiler"下的命令字段中添加-m32"(该字段现在应该显示为g++ -m32").对GCC/G++ 链接器"执行相同操作.

Then right click on your project, and select "properties". Go to "C/C++ Build" and choose "settings". Under "GCC/G++ Compiler" add "-m32" to the command field (the field should now say "g++ -m32"). Do the same for "GCC/G++ Linker".

现在你已经添加了标志,这应该被编译为 32 位.我正在使用 Eclipse Galileo,因为您的界面看起来不同.我只在发布"配置文件下添加了-m32"标志,所以我的调试"版本仍然是 64 位.

Now that you have added the flag, this should be compiled for 32bit. I'm using Eclipse Galileo, for the case that your interface looks different. I only added the "-m32" flag only under the "Release" profile, so my "Debug" builds are still 64bit.

这篇关于如何使用 Eclipse 编译 32 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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