LLVM is an open-source compiler architecture that has been successfully applied to multiple application areas. Clang is a compiler front-end for LLVM, which currently supports programming languages such as C, C + +, objective-c, and objective-c++. Clang to the source program lexical analysis and semantic analysis, and convert the analysis results into AST (abstract syntax tree), and finally use LLVM as the generator of back-end code. Clang's development goal is to provide a front-end compiler that can replace GCC. Compared to GCC, Clang is a redesigned compiler front end with a number of advantages, such as modularity, code simplicity, low memory footprint, and ease of expansion and reuse. Due to the excellent design of the Clang, the Clang is well suited for the design of source code level analysis and conversion tools.
Today, we will briefly describe how to install and configure clang and further clang-based programming under the Windows platform using Visual Studio. First, the following tools are required to compile clang under Windows: ①
SVN。 The source code used to pull the clang. : Https://tortoisesvn.net/downloads.html② version in
-And above the
Visual Studio。 : Https://www.visualstudio.com/zh-cn/downloads/download-visual-studio-vs.aspx③
Python。 For clang test. : Https://www.python.org/downloads/④
CMake。 The solution file used to generate vs. : http://www.cmake.org/cmake/resources/software.html
Next, it's
steps to compile clang:
① Pull the source of LLVM。 At the command line, enter: SVN co http://llvm.org/svn/llvm-project/llvm/trunk LLVM
② Pull the source of Clang。 In the current directory input: CD llvm\tools into the subdirectory, enter: SVN co http://llvm.org/svn/llvm-project/cfe/trunk clang
③ using CMake to generate vs solution files。 First, go back to the beginning of the LLVM directory and create a new folder build in the same directory as its peers. Next, enter the corresponding command in the build folder, based on the corresponding installed VS version, Cmake-g "Visual Studio XXX" on the command line. \LLVM which, in XXX, replace the current VS version, for example: If the 2013 version of the input 12, if the 2015 version of the input 14. If this step succeeds, you can see the corresponding. sln file in the build. ④
Build Clang。 If the above steps are successful, then open the Llvm.sln file directly and select the All_build project to build. This process can take a few hours. ⑤
Complete。 If the previous step succeeds, you can see that the build\debug\bin contains multiple executables such as Clang.exe. You can add the path to the environment variable at this point, and finally you can enter clang--help on the command line to test to see if it can be executed.
At this point, the complete process of clang configuration under the Windows platform is complete.
VisualStudio-based Clang installation and configuration under Windows platform