libstc++ with clang 3.3

clang++ does create an .bc file for the following program. But when I run
this with lli, it always gives an error related with libstdc++.

Is there some problem in clang 3.3? How can I tell clang++ to include
libstdc++ when compiling?

This problem only comes with .cpp extension, there's no problem with .c

My code:


using namespace std;

int main() {

cout<< "Hello World" <<endl;

return 0;


Which error are you seeing? -stdlib=libstdc++ should work?

Hello Bastein,

I did include -stdlib=libstdc++ in the command line. Clang does generate a
.bc file, but when I run the .exe file, the program crashes immediately.
Windows gives the following error: "Your application has stopped working".

I think it has something to do with libstdc++-6.dll.

Well, you should have pointed out that you are using Windows in the first place.


So what can be done on windows to resolve this problem?


If you’re using mingw, make sure you’re using the right OS in the triple. This is usually a flag like --target=i686-pc-mingw32. clang may be defaulting to an OS of win32, which has a slightly different C ABI w.r.t. passing records by value, bitfields, and other little things.

You should also try to get a stack trace with gdb to get more information.