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

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

问题描述

我目前在我的64位Ubuntu电脑上用c ++写一个小程序。默认情况下eclipse编译64位架构的程序。因为我想在我的服务器上使用我的小程序,仍然是32位,我需要能够编译我的程序为32位。我怎么能在eclipse中这样做?我已经花了一段时间的设置,但没有什么工作...

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 ++ with multilib

  • gcc/g++ with multilib

ia32-libs

ia32-libs

,然后选择属性。
转到C / C ++ Build并选择settings。在GCC / G ++编译器下,将-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天全站免登陆