What do you need to install to use Clang on windows to build c++14 for 64 bit?

后端 未结 3 1315
轮回少年
轮回少年 2021-01-30 10:21

UPDATE:

I\'ve written a detailed tutorial that incorporates the top two answers on this question: http://blog.johannesmp.com/2015/09/01/installing-clang-on-windows-pt1/

相关标签:
3条回答
  • 2021-01-30 10:52

    You can install llvm pre-release binary for Windows here. MinGW-w64 can be downloaded here. Of course, you should make sure the paths are properly set up.

    For the latest version of clang, e.g., clang 6.0.0. The above solution by @user5271266 will not be enough. Now the default target for clang Windows is x86_64-pc-windows-msvc (Assume that you are using 64 bit Windows).

    In order to compile C++ source files, according to here, we should change the target:

    clang++ -target x86_64-pc-windows-gnu -std=c++14 test.cc -o test.exe
    
    0 讨论(0)
  • 2021-01-30 11:05

    if you use the upcoming clang 3.7.0, simply set PATH to include mingw-w64's bin, clang will work as you expect

    0 讨论(0)
  • 2021-01-30 11:14

    Try installing MSYS2 and then installing the mingw-w64-x86_64-clang (binary) package:

    pacman -S mingw-w64-x86_64-clang
    

    It is a bit old at the moment (3.6.2), but it might be good enough for you. Then when you run the Win64 shell provided by MSYS2, clang will be on your path.

    If it's not good enough, I have recently been building a 64-bit version of clang with MSYS2 and using it to compile native 64-bit Windows executables. My process was something like:

    1. Use pacman to install base-devel, mingw-w64-x86_64-ninja, mingw-x86_64-cmake and perhaps some other packages that are needed by the build process.
    2. Grab my PKGBUILD script for clang and the files in the same directory. This is based on the mingw-w64-clang-svn package from MSYS2, which is largely the work of Martell Malone. You can find him on the MSYS2 IRC channel and ask him more about it.
    3. In a Win64, shell, go to the directory with my PKGDUILD, run export MINGW_INSTALLS=mingw64 (so you are only compiling the 64-bit version), and then run makepkg-mingw.

    It is unlikely you will get everything right on the first try, and some files might need to be edited. Clang may have changed since the last time I did this and some patches might not apply cleanly.

    0 讨论(0)
提交回复
热议问题