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

Christopher Jones chrisjones.lambda at gmail.com
Thu Mar 1 22:06:21 PST 2012


Something else that may help:  when I try to use llc to generate native assembly, I see that I have a linking problem:

$ llc hello.bc -o hello.s
$ g++ hello.s -o hello.native
In function `main':
hello.bc:(.text+0x11): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
hello.bc:(.text+0x3b): undefined reference to `std::ctype<char>::_M_widen_init() const'
collect2: ld returned 1 exit status

What should I do to modify the following line to link to the standard library?
$ clang++ -O3 -emit-llvm hello.cpp -c -o hello.bc

I'll also mention that when I try this exercise using a C program and clang instead of clang++, lli works fine.

Thanks,
Chris

On Mar 1, 2012, at 10:50 PM, 陳韋任 wrote:

>> $ 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!
> 
>  What version of LLVM and Clang you are using? I have no such problem
> on my machine.
> 
> Regards,
> chenwj
> 
> -- 
> Wei-Ren Chen (陳韋任)
> Computer Systems Lab, Institute of Information Science,
> Academia Sinica, Taiwan (R.O.C.)
> Tel:886-2-2788-3799 #1667
> Homepage: http://people.cs.nctu.edu.tw/~chenwj





More information about the llvm-dev mailing list