25

I am open to either a Visual Studio answer or a MinGW answer. I just finished building LLVM 3.2 using CMake and Visual Studio 2010. Everything went smoothly, but I have no llvm-config. Do I need it? Every example I see on the intertubes makes use of that tool. If I don't need it, how do I configure my project to make use of LLVM?

To be clear, I am not trying to use LLVM tools/compilers (like clang and whatnot). I am trying to write C++ code that uses the LLVM libraries to produce LLVM IR and even compile that stuff. I setup my include and lib folders. I ran llvm-config in Linux and saw a long list of macros and libraries.

I have a wonderful folder full of goodies. It just has no llvm-config in there: C:\Program Files (x86)\LLVM\

TheBuzzSaw
  • 8,648
  • 5
  • 39
  • 58

2 Answers2

22

llvm-config does not exist in windows prebuilt binaries. You need to compile from the source code to get it.

  1. Grab CMAKE > 3.5 , install it and make sure you add it to PATH.
  2. Download Visual Studio 2019
  3. Donwload the source code (9.0.1 is the latest as I'm writing this)
  4. Extract the source code
  5. Cd into the root of the llvm source-code
  6. In cmd, type cmake . this will generate Visual Studio 2019 sln.
  7. open sln file(LLVM.sln), change the build type to Rlease, build the whole project
  8. navigate to your Rlease\bin, and there you have your llvm-config.exe
Hossein
  • 24,202
  • 35
  • 119
  • 224
  • 6
    It would have saved me a day of figuring this out, but you have to run cmake in a "Developer PowerShell for VS 2019" window (in your Start menu), not in just regular PowerShell. Otherwise, include and link dirs for the Windows toolkit will not be found. – cheater Dec 07 '20 at 17:43
  • 3
    when installing VS, you have to tick "Desktop Development with C++" under "Workloads". It's the big visual panel with a lot of smaller rectangles and large icons. You will see some checkboxes on the right, some will be checked. No need to touch any of that, the default selection will suffice. – cheater Dec 07 '20 at 17:46
  • 1
    As of recently, you don't have to do this. LLVM has prebuilt executables now. – flm Dec 30 '22 at 13:19
  • @flm Where can I find prebuilt executables? – Koll Mar 03 '23 at 19:37
  • @Koll in official releases on GitHub: https://github.com/llvm/llvm-project/releases . Search for `exe` downloads. – flm Mar 05 '23 at 11:52
  • 2
    @flm from what I can see, the pre-build executables are missing llvm-config. The only thing returned by globbing *config* are `lib/clang/16/include/pconfigintrin.h`, `lib/cmake/llvm/LLVMConfigExtensions.cmake` and `lib/libear/config.h.in`. – mcmikecreations May 18 '23 at 13:17
  • 1
    Thanks, this works, but it was a pain. Instead of just running ``cmake .`` I had to create a build directory in llvm-project, and then run ``cmake -S llvm -B build -G "Visual Studio 17 2022" -A x64 -DLLVM_ENABLE_PROJECTS='clang' -DCMAKE_BUILD_TYPE=Release``. Then I went into the build directory which was where LLVM.sln was. – SpencerLS Jul 18 '23 at 07:51
6

If you have built the LLVM in debug version all the executables (including llvm-config) have been placed in your build directory (containing Visual Studio project and solution files) in bin/Debug/ subdirectory. In case of release build replace Debug with Release.

If you are interested in using LLVM on Windows more than building it, check out Windows snapshot builds.

Paweł Bylica
  • 3,780
  • 1
  • 31
  • 44
  • 4
    I've installed the latest windows snapshot build and `llvm-config` won't be available, do you know why? – BPL Jan 09 '20 at 20:29