Program built with clang++.exe crashes

I have dual-boot Windows 7 and Ubuntu Trusty. I used clang/clang++ and it works fine when I installed it on Ubuntu with sudo apt-get install clang.
I am now trying to set up Clang on Windows 7 x86. I installed it using an .exe installer. clang -o hello hello.c -std=c11 compiles, links and runs fine. But when I use clang++ -o helloCpp helloCpp.cpp -std=c++11, it compiles and links fine, but when I run it, the program displays
Hello, world!
and crashes (Windows shows "helloCpp.exe has stopped working..."). What is wrong here?

Thanks in advance.

Note: I tried building Clang from source, but everything freezes and I can't stop the compilation, because my hardware sucks.
Getting clang working on windows yourself is a pain. Just use the prebuilt windows snapshots for Visual Studio:
http://llvm.org/builds/
http://i.imgur.com/NqbwtrT.png?1
Trust me, I have spent months and this is the best option for Windows currently. You will not be able to use clang from the commandline, and the current snapshots do not support exceptions.

If you want to use clang with CMake:
cmake -G "Visual Studio 12 2013" -T LLVM-vs2013 -DCMAKE_CXX_FLAGS="-D_HAS_EXCEPTIONS=0 -Xclang -std=c++1z" ../

Unfortunately some Visual Studio's headers have to be slightly modified in certain cases as the _HAS_EXCEPTIONS flag is not supported fully by Microsoft. But trust me, it a lot less hair pulling than doing it yourself ;p
Last edited on
Do you have any idea why C code runs normally, but C++ code crashes?
Have you looked at what libraries are being linked in each case?
Topic archived. No new replies allowed.