2011-10-10 2 views
1

최근 우분투 시스템에서 Clang 2.9 (here)를 컴파일했습니다. 간단한 프로그램을 컴파일하고 링크하는 데 문제가 있습니다. 누구든지이 문제를 해결하는 방법을 알고 있습니까? 여기에 출력 내가 볼 것 :clang을 사용하여 프로그램을 컴파일하고 연결할 수 없습니다.

[email protected]:~/Desktop$ clang add.c 
/usr/bin/ld: 1: Syntax error: word unexpected (expecting ")") 
clang: error: linker command failed with exit code 2 (use -v to see invocation) 

끝나면 uname -a 출력

Linux ubuntu 2.6.38-8-generiC#42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux 

의 gcc -v 출력 :

Using built-in specs. 

COLLECT_GCC=gcc 

COLLECT_LTO_WRAPPER=/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/lto-wrapper 

Target: i686-linux-gnu 

Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4 --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=i386-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/i386-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/i386-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu 

Thread model: posix 

gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) 

연타 자세한

,691 OUPUT
clang version 2.9 (tags/RELEASE_29/final) 

Target: i386-pc-linux-gnu 

Thread model: posix 

"/usr/local/bin/clang" -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name add.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu pentium4 -target-linker-version 2.21.0.20110327 -momit-leaf-frame-pointer -v -resource-dir /usr/local/bin/../lib/clang/2.9 -ferror-limit 19 -fmessage-length 138 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-JJruTv.o -x c add.c 

clang -cc1 version 2.9 based upon llvm 2.9 hosted on i386-pc-linux-gnu 

#include "..." search starts here: 

#include <...> search starts here: 

/usr/local/include 

/usr/local/bin/../lib/clang/2.9/include 

/usr/include 

End of search list. 

"/usr/bin/ld" --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o a.out crt1.o crti.o crtbegin.o -L -L/../../.. /tmp/cc-JJruTv.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtend.o crtn.o 

/usr/bin/ld: 1: Syntax error: word unexpected (expecting ")") 

clang: error: linker command failed with exit code 2 (use -v to see invocation) 
+2

add.c에 무엇이 있습니까? – wormsparty

답변

2

링커 스크립트에 문제가있는 것 같습니다. 그러나 위의 ld 줄은 특정 링커 스크립트를 포함하지 않으므로 기본 링커 스크립트를 사용해야합니다 (단순히 ld -v을 입력하십시오).

-L -L/../../.. 조금 이상해 보입니다. 그래도 어디에서 왔는지 확실하지는 않지만 원래의 행에는 표시되지 않습니다. 아마도 설치가 망가 졌을까요?

gcc -v add.c을 수행하고 /usr/bin/ld을 호출하는 행을 비교하십시오. 아마도 질문에 추가하십시오.

+0

도움에 감사드립니다. '/ usr/bin/ld' 파일이 다른 파일로 덮어 씌워졌습니다. 어떻게되었는지는 잘 모르겠지만'gcc -v add.c'의 결과를 조사해 봄으로써 그 결정을 내릴 수있었습니다. 나는/usr/bin/ld를 대체하고 결국 모든 것을 얻었습니다. – Jason

관련 문제