2
votes

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

2
Is Eclipse using the same path as your shell? The error says 'PATH=[/usr/bin:/bin:/usr/sbin:/sbin]' but llvm-ld is likely somewhere like /opt/local/bin.matt
Where can I find out what path Eclipse is using?Jay Soyer
Sorry, it's been a while since I used Eclipse, and then it was only Java - I've not used CDT. You'll have to look through the Eclipse's preferences and see if you can find it.matt
found it under build variables. Updated the path settings. Still gives the same error. Oddly enough, when it prints the PATH= line it still doesn't contain the newly added path. I tried cleaning, then building, restarting, and verified all that the newly added path was still there. No dice.Jay Soyer

2 Answers

6
votes

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.

0
votes

I faced a similar problem and made a modification in the Eclipse Preferences -> C/C++ -> Build -> Environment. Choose 'Select...', 'PATH', 'Edit...' and add the location of your llvm-ld executable. The project then built correctly for me.