错误试图建立一个胖通用二进制在Ubuntu的gcc [英] Error trying to build a fat universal binary with gcc on Ubuntu
问题描述
我试图运行一个非常简单的code,但它报告错误,任何人都可以给一些建议?我使用Ubuntu14和gcc4.9。
鑫@ Ubuntu的:〜/ $管道GCC -arch i386的-arch x86_64的channel.cpp
GCC:错误:386:没有这样的文件或目录
GCC:错误:x86_64的:没有这样的文件或目录
GCC:错误:无法识别的命令行选项-arch
GCC:错误:无法识别的命令行选项-arch
看起来你要使用编译code到通用二进制2架构的苹果OS / X(达尔文)GCC /铛方法。
这是Linux(包括Ubuntu)不同。 Linux没有一个可执行多个目标通用二进制支持。它是每个构建一种体系结构。删除 -arch i386的-arch的x86_64
和 -m32
替换它,如果你的目标是32位的二进制,并且 -m64
如果定位一个64位二进制。
32位:
的gcc -m32 channel.cpp
64位
的gcc -m64 channel.cpp
的特殊注意事项
您可能还需要安装的 multilib的的版本的 GCC 的(和 G ++ 的,如果你愿意的话),这样就可以正确地构建和运行使用适当的 C 的库,在64位的Ubuntu 32位应用程序。可以使用此命令行来完成:
sudo易于得到安装gcc-multilib的克+ + - multilib的
在其他非的Ubuntu基于Debian的系统,你可能需要使用:
apt-get的安装gcc-multilib的克+ + - multilib的
I try to run a very simple code, but it reports error, can anyone give some suggestions? I am using Ubuntu14 and gcc4.9.
xin@ubuntu:~/pipes$ gcc -arch i386 -arch x86_64 channel.cpp
gcc: error: i386: No such file or directory
gcc: error: x86_64: No such file or directory
gcc: error: unrecognized command line option ‘-arch’
gcc: error: unrecognized command line option ‘-arch’
Looks like you are trying to use the Apple OS/X (Darwin) GCC/CLang method of compiling code to a universal binary with 2 architectures.
It is different on Linux (including Ubuntu). Linux doesn't have universal binary support for multiple targets in a single executable. It is one architecture per build. Remove -arch i386 -arch x86_64
and replace it with -m32
if you are targeting a 32-bit binary, and -m64
if targeting a 64 bit binary.
32-bit:
gcc -m32 channel.cpp
64-bit
gcc -m64 channel.cpp
Special Considerations
You may also have to install the Multilib versions of GCC (and G++ if you want to) so that you can properly build and run 32-bit applications on 64-bit Ubuntu using the appropriate C libraries. That can be done with this command line:
sudo apt-get install gcc-multilib g++-multilib
On other non-Ubuntu Debian based systems you'd need to use:
apt-get install gcc-multilib g++-multilib
这篇关于错误试图建立一个胖通用二进制在Ubuntu的gcc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!