Ubuntu 上 Eclipse CDT 的 32/64 位问题
我最近刚刚开始在我的 PC 上运行 Linux,并且正在尝试开始学习 OpenGL。我使用最新版本的 Eclipse CDT 作为我的 IDE,我的系统是 Ubuntu 10.10,64 位版本。
我遇到的问题是,每当我尝试从 IDE 中运行构建时,我都会收到错误消息“启动失败。未找到二进制文件。”
我在网上查了很多资料,但仍然无法解决问题。我知道二进制文件已构建,可以从终端窗口运行。根据我看到的帖子,问题是 Eclipse 尝试运行 32 位二进制文件,但 GCC 4.4.5 在 64 位系统上默认为 64 位二进制文件。 * 编辑 * 这个是我收集上述信息的地方
我已经看到了很多有关在 makefile 中使用 -m32 标志的信息,但是我仍然在 Eclipse 中得到以下输出:
make all
g++ -o HelloWorld2 main.o
/usr/bin/ld: i386 architecture of input file `main.o' is incompatible with i386:x86-64 output
/usr/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status
make: *** [HelloWorld2] Error 1
我想知道的是如何让 Eclipse 启动 64 位二进制文件,或者让 Eclipse 正确编译 32 位二进制文件。
I have just recently started running Linux on my PC and I am trying to start learning OpenGL. I am using the latest version of Eclipse CDT as my IDE, and my system is Ubuntu 10.10, 64 bit version.
The problem I am having is that whenever I try to run a build from within the IDE I get the error message "Launch Failed. Binary Not Found."
Ive done a lot of looking around on the internet but I still cant solve the problem. I know for a fact that the binary is built, it can be run from a terminal window. According to posts I have seen the problem is that Eclipse tries to run a 32 bit binary, but GCC 4.4.5 defaults to 64 bit binaries on a 64 bit system.
* Edit * This is where I gathered the above information
Ive seen a lot of information about using the -m32 flag in makefiles, but then I still get the following output in Eclipse:
make all
g++ -o HelloWorld2 main.o
/usr/bin/ld: i386 architecture of input file `main.o' is incompatible with i386:x86-64 output
/usr/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status
make: *** [HelloWorld2] Error 1
What I would like to know is how to either get Eclipse to launch the 64 bit binaries, or have Eclipse correctly compile 32 bit binaries.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(我能够重现您描述的错误,所以我的答案是基于“逆向工程”错误)。
在 Eclipse 项目窗格中,右键单击该项目并转到“属性”。在
C/C++ Build
下 ->设置
,单击Binary Parsers
选项卡,并验证是否选中Elf Parser
。 (我不确定它是否需要成为唯一检查的解析器)。顺便说一句,您可以使用 readelf -h myBinary.o 并查看 Class 字段来验证二进制文件的类。
关于运行 32 位二进制文件,也许这篇文章会有所帮助:http://stefaanlippens.net/32bit_executable_on_64bit_machine
(I was able to reproduce the error you describe, so my answer is based on 'reverse-engineering' the error).
In the eclipse projects pane, right-click the project and go to 'properties'. Under
C/C++ Build
->Settings
, click theBinary Parsers
tab, and verify thatElf Parser
is checked. (I am not sure if it needs to be the only checked parser).Btw, you can verify the class of your binary file using
readelf -h myBinary.o
and looking at theClass
field.Regarding running the 32-bit binary, maybe this post is helpfull: http://stefaanlippens.net/32bit_executable_on_64bit_machine