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
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
$ lli -version
LLVM version 3.1svn
DEBUG build with assertions.
Built Feb 29 2012 (17:54:38).
Default target: x86_64-unknown-linux-gnu
$ clang -v
clang version 3.1 (3edf02f66d339a3ae6d06aeb96c78d9089b53bc1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Thanks,
Chris
$ 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:
Hello all,
I'm brand new to using LLVM and am having trouble using lli with a C++ program. I tried to compile the following:
#include<iostream>using namespace std;int main(){cout << "Hello, world!" << endl;return 0;}
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.bcLLVM 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.Thanks!
Chris
...
> 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.