[LLVMdev] (Newbie) Using lli with clang++?

Duncan Sands baldrick at free.fr
Thu Mar 1 23:13:46 PST 2012


Hi,

...
> When I compile directly to an executable with the following command, all is well:
> $ clang++ -O3 hello.cpp -o hello
>
> But when I try to produce a bitcode file, I get an error:
>
> $ clang++ -O3 -emit-llvm hello.cpp -c -o hello.bc
> $ lli hello.bc
> LLVM ERROR: Program used external function
> '_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l'
> which could not be resolved!
>
> I'm running this on x86_64.  I'd appreciate any help about what I'm doing wrong.

first off you need to build with FFI support (configure with --enable-libffi).
Then you doubtless need to pass libstdc++ to lli, like this (IIRC):
-load=libstdc++.so
When you compile with clang++ it automagically adds the C++ standard library
to the list of things to link with, which is why you don't notice that the
linker is getting passed libstdc++.so.  As lli is doing linking too, it also
needs libstdc++.so.

Ciao, Duncan.



More information about the llvm-dev mailing list