I have Clang installed with MSYS2, and libc++ installed too. With C:\msys64 being "root" (/), the libc++ headers are at /mingw64/include/c++/v1/, the libc++ DLL is at mingw64/bin/, and the libc++ libraries (.a) are at /mingw64/lib/. But when trying to compile a simple Hello World program using only C++ <iostream>
, clang helloworld.cpp -o helloworld.exe -v --stdlib=libc++
returns a ton of errors, presumably with linking. There are a lot of undefined references. I presume this is name mangling, but as the libc++ libraries and libc++ abi are made for Clang, it might be something different.
I also noticed the errors came from the ld linker, however, I have lld on my path.
Asked
Active
Viewed 16 times
0

0x1a4
- 111
- 6
-
3you need to compile and link c++ code with `clang++` not `clang` – Alan Birtles Aug 20 '20 at 14:18
-
I thought clang could detect C++ code and automatically use clang++. That solved it – 0x1a4 Aug 20 '20 at 14:20
-
1no, it inherits its behaviour from gcc, it does detect that it is compiling c++ code so compiles but doesn't automatically add the required linker flags so wont link – Alan Birtles Aug 20 '20 at 14:22