LLVM-Clang for Eclipse CDT on MAC OS X

compiler-errorseclipse-cdtllvm-clangosx-lion

Having trouble getting LLVM-Clang compiling through Eclipse. Just testing it out on a hello world example that comes default with CDT. Its giving the following error:

clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/Test.bc ../src/Test.cpp
llvm-ld -v -native -o Test src/Test.bc
Internal Builder: Cannot run program "llvm-ld": Unknown reason
Error: Program "llvm-ld" is not found in PATH

PATH=[/usr/bin:/bin:/usr/sbin:/sbin]
Build error occurred, build is stopped

I'm not sure why its complaining about PATH because I can invoke the clang++ and llvm-ld commands through the terminal just fine. In fact, when I typed the above through Terminal I get the following error.

clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/Test.bc ../src/Test.cpp
llvm-ld -v -native -o Test Debug/src/Test.bc
Linking bitcode file 'Debug/src/Test.bc'
llvm-ld: error: Cannot load file 'Debug/src/Test.bc': Bitcode file 'Debug/src/Test.bc' could not be loaded: unknown type in type table

So it might not be an Eclipse issue? Never been much of a command line compile guy so my knowledge there is limited.

I'm running Lion. Installed clang via XCode Command Line tools. Installed LLVM via Macports. Had to manually set my pathing for LLVM.

Clang -v says 3.1
LLVM is v3.0

Best Answer

In the project properties > C/C++ Build > Settings select the LLVM C++ Linker then substitute the llvm-ld command with clang++ (the XCode command line tool do not have the llvm-ld linker... let clang++ figure out to call the linker).

I've tested it using the llvm4cdt Eclipse plugin.

Related Topic