How to build clang on Windows

DoxyPress requires a unique project file for configuration and setup. The project file contains tags which are used to select which output formats should be generated, what should be generated, and numerous other parameters. There is a tag which can be set to instruct DoxyPress to use Clang for parsing C and C++ files.

Since DoxyPress is compiled and linked with the libclang dll we had to build clang on Windows. The steps listed below build a version of clang which does not depend on MSVC.

MinGW-w64

For more information about specific versions and where to download the files, refer to Installing MinGW-w64

CMake

Download the Zip file from CMake

Extract the CMake zip file. Add /c/CMake to your bash profile or path.

Minimum recommended version of CMake is 3.16

Python 3.9

Download the installer from Python 3.9

Run the Python Windows installer. Add /c/Python39 to your bash profile or path.

Ninja

Ninja is used instead of make. In order to install Ninja git needs to be in your path. Follow the steps listed below and do not forget the period at the end of step two.

  • cd /c/ninja
  • $ git clone git://github.com/martine/ninja.git .
  • $ git checkout release
  • ./configure.py --bootstrap --host=mingw --platform=mingw

Add /c/Ninja to your bash profile or path.

Minimum recommended version of Ninja is 1.6

Installing Clang Source Code

  1.  From the following link locate 'Download LLVM'    LLVM Download Page
  2.  Download the LLVM source code and the Clang source code tar files for 10.0.1

From a root or project directory:

  • md clang
  • cd clang

  • md build
  • md llvm

  • cd llvm
  • Extract llvm tar file ( clang/llvm )

  • cd tools
  • md clang
  • cd clang
  • Extract clang tar file ( clang/llvm/tools/clang )

  • cd ../../../build

Building (from clang/build)


  • To configure and build the 32-bit version of Clang use the following syntax:
    • CFLAGS=-m32 CXXFLAGS=-m32 cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ../llvm
    • ninja

  • To configure and build the 64-bit version of Clang use the following syntax:
    • cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ../llvm
    • ninja

If you have any questions about these instructions feel free to email us at info [at] copperspice.com