I have a project that compiles fine under GCC 12.2.0. I would like to compile it under Clang 11.0.0, but cannot.
This project uses the Boost library. (1.81)
When I tried to compile under Clang, I got the following error relatively early on:
In file included from /C/msys64/mingw64/include/boost/qvm/vec.hpp:10:
/C/msys64/mingw64/include/boost/qvm/assert.hpp:10:12: fatal error: 'cassert' file not found
# include <cassert>
What I have tried so far:
Swapping stdlib between libc++ and libstdc++, neither worked
Installing the mingw-w64-clang-x86_64-boost under mingw64. I could not figure out how to use Boost_ROOT to point cmake to the correct boost version. (And it turns out this approach was faulty anyways)
Using the clang64 shell instead of the mingw64 shell, along with the appropriate clang-specific packages
Nothing has worked so far though. It still fails on that cassert include.
Here is what I needed to know to fix this:
1: MSYS provides a clang64 shell for doing anything clang-related. It must be used for compiling anything with Clang on MSYS2!
2: The mingw64 and clang64 shells share the same package repository. Anything installed one one will appear in the other.
3: Clang was severely outdated (11.0.0) and the newest version (15.0.07) does not have this issue. Pacman -Syyuu did not find this. Wiping all clang packages and reinstalling them fixed it.
4: I was pointing cmake to the wrong clang executable. I was using (-DCMAKE_C_COMPILER=/usr/bin/clang.exe) when I should have been using (-DCMAKE_C_COMPILER=/clang64/bin/clang.exe) [and the clang++ as well]