Skip to main content

llvm + clang + MinGW

Posted in

I believe that this post looks weird to everybody (even me) because it described the installation of llvm/clang on Windows.

Step 1. Get MinGW here . I got MinGW-5.1.6. Install it

Step 2. Get CMake here . I got 2.8.1.

Step 3. Get LLVM and Clang source code here here . I got 2.7.

Step 4. Extract llvm sources. Let E:\LLVM be our working directory. After this step we are supposed to have llvm sources in E:\LLVM\llvm-2.7.

Step 5. Extract clang sources to E:\LLVM\llvm-2.7\tools. After this step we are supposed to have clang sources in E:\LLVM\llvm-2.7\tools\clang-2.7. However, this is not how it should be. Rename clang-2.7 to clang.

Step 6. Go to E:\LLVM\llvm-2.7. Create a build directory, let it be BUILD.

Step 7. Go to E:\LLVM\llvm-2.7\BUILD.

Step 8. Run

"C:\Program Files\CMake 2.8\bin\cmake.exe" -G "MinGW Makefiles" ..

Step 9. After the configuring is done run

C:\MinGW\bin\mingw32-make

This will take some time to get llvm and clang built. Take a break and then have fun.

building clang llvm on mingw

Hi,
I wish to use clang with Code::Blocks on windows, but there is no binary for Windows in the llvm.org. I decide to build them but see these errors. Can you suggest me how to do?

C:\llvm-2.7\BUILD> C:\CodeBlocks\cmake-2.8.2-win32-x86\bin\cmake.exe -G "MinGW Makefiles" C:\llvm-2.7

CMake Error: CMake was unable to find a build program corresponding to "MinGW Ma
kefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a differe
nt build tool.

CMake Error: CMake was unable to find a build program corresponding to "MinGW Ma
kefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a differe
nt build tool.

CMake Error: Error required internal CMake variable not set, cmake may be not be
built correctly.

Missing variable is:
CMAKE_C_COMPILER_ENV_VAR

CMake Error: Error required internal CMake variable not set, cmake may be not be
built correctly.

Missing variable is:
CMAKE_C_COMPILER

CMake Error: Could not find cmake module file:C:/llvm-2.7/BUILD/CMakeFiles/CMake
CCompiler.cmake

CMake Error: Error required internal CMake variable not set, cmake may be not be
built correctly.

Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR

CMake Error: Error required internal CMake variable not set, cmake may be not be
built correctly.

Missing variable is:
CMAKE_CXX_COMPILER

CMake Error: Could not find cmake module file:C:/llvm-2.7/BUILD/CMakeFiles/CMake
CXXCompiler.cmake

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Why cmake is in CodeBlocks

Why cmake is in CodeBlocks install dir? Does CodeBlocks install it with itself? First thing to do is to install cmake separately. The other thing to try is set all those environment variables (but this current behaviour looks like cmake has been misconfigured).

You need to make sure that

You need to make sure that g++/gcc is in your system PATH (the entire MinGW bin directory)
otherwise it wont work

CMake cannot find mingw32-make.exe

make sure the path of mingw32-make.exe in ur path
ex:
set path=C:\MinGW\bin;%PATH%

building clang llvm on mingw

Hi,
thank you for your answer!
Cmake is not installed with mingw itself, but simply unpacked to mingw`s root. Maybe does I need to get an installer to set environment in itself? Where "environment" can be set manually in Windows 7?

anta40

I'm experiencing a similar error:
C:\llvm\llvm-2.8\build>C:\cmake-2.8.3-win32-x86\bin\cmake.exe -G "MinGW Makefiles" ..
CMake Error at C:/cmake-2.8.3-win32-x86/share/cmake-2.8/Modules/CMakeMinGWFindMake.cmake:20 (ME
SSAGE):
sh.exe was found in your PATH, here:

C:/msys/bin/sh.exe

For MinGW make to work correctly sh.exe must NOT be in your path.

Run cmake from a shell that does not have sh.exe in your PATH.

If you want to use a UNIX shell, then use MSYS Makefiles.

Call Stack (most recent call first):
CMakeLists.txt:3 (project)

CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAK
E_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAK
E_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctl
y.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctl
y.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:C:/llvm/llvm-2.8/build/CMakeFiles/CMakeCCompiler.
cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctl
y.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctl
y.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:C:/llvm/llvm-2.8/build/CMakeFiles/CMakeCXXCompile
r.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Well, I actually already removed sh.exe from PATH, and gcc/g++ is still in PATH.

don't use -G "MinGW Makefiles" with MSYS

if u use MSYS env, please exec cmake.exe -G "MSYS Makefiles" somedir, cmake will find make.exe and /bin/sh
other way, as cmake.exe -G "MinGW Makefiles" somedir, cmake will find mingw32-make.exe and not /bin/sh

quick note

The clang file is packed as a dir clang-x.y (e.g. clang-2.8). You need to rename this to clang or cmake won't find it.

Re: quick note

Yes, that's what I'm doing in Step 5.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
                  o        o     OoooOOoO  .oOOOo.  
.oOOo. OooOoO O O o o o
O o o o O O.
o O o O o `OOoo.
O' O O OoOo. O `O
O O O o o o o
.O o o . o O O O. .O
oOoOoO O OOoOooO O o OOooOooO `oooO'

Enter the code depicted in ASCII art style.