简体   繁体   English

lang链接器和i686

[英]Clang linker and i686

When I try to compile C program with Clang compiler I get this message 当我尝试使用Clang编译器编译C程序时,收到此消息

/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../lib/crt1.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../lib/crti.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../lib/crtn.o' is incompatible with i386 output
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How I can fix this problem? 我该如何解决这个问题? If it's important: 如果很重要:

$ uname -a
Linux asus 3.0.0-17-generic #30-Ubuntu SMP Thu Mar 8 17:34:21 UTC 2012 i686 i686 i386 GNU/Linux

The clang compiler is essentially telling that the source code in question is using the x86-64 processor extension (also known as amd64 and '64-bit processor') but you are trying not to {ie use only the i386 architecture which is also used (and extended) by i[456]86 }.That is the default on 32 bit processors. clang编译器实质上是在说问题源代码正在使用x86-64处理器扩展(也称为amd64和“ 64位处理器”),但您尝试不使用{即仅使用也使用的i386体系结构(并由i [456] 86扩展)。这是32位处理器上的默认设置。 Most likely, you downloaded the wrong version (64-bit vs the intended 32-bit) of the software you are trying to compile. 您很可能下载了试图编译的软件错误版本(64位和预期的32位)。

You are linking 64 bits library with 32 bit library. 您正在将64位库与32位库链接在一起。 That mixing creating the errors. 混合造成错误。 You can check architecture in linux by "objdump" command and for windows you can use dependency walker. 您可以通过“ objdump”命令检查linux中的体系结构,对于Windows,可以使用依赖项遍历器。 I have also faced same problem. 我也面临同样的问题。 If you are using linux you should modify it by using -m64 command instead of -m32. 如果使用的是Linux,则应使用-m64命令而不是-m32对其进行修改。 -m64 command is for building 64 bit library and -m32 is for building 32 bit library. -m64命令用于构建64位库,-m32命令用于构建32位库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM