简体   繁体   中英

Clang linker and i686

When I try to compile C program with Clang compiler I get this message

/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. Most likely, you downloaded the wrong version (64-bit vs the intended 32-bit) of the software you are trying to compile.

You are linking 64 bits library with 32 bit library. That mixing creating the errors. You can check architecture in linux by "objdump" command and for windows you can use dependency walker. I have also faced same problem. If you are using linux you should modify it by using -m64 command instead of -m32. -m64 command is for building 64 bit library and -m32 is for building 32 bit library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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