How to compile the C file that uses LLVM on Windows?

I have installed LLVM by LLVM-16.0.0-win64.exe on windows. But it doesn’t include llvm-config tool. What is the command line to compile my c file that include like #include “llvm/IR/LLVMContext.h”? I cannot find LLVMContext.h in installation folder.

How to compile my c file manually without llvm-config and make file on windows? My compiler is MinGW

Without using CMake to include LLVM’s modules (which have been updated to not use llvm-config, I believe, but I’m hoping someone will correct me if I’m wrong), you’ll have to manually add the proper -I, -L, and -l arguments (or -Wl,-L and -Wl,-l arguments). Also, keep in mind that if you’re including files such as llvm/<anything> and not llvm-c/<anything>, you’re using the C++ API, so your source file should be C++ instead of C.

For example, if you installed LLVM to "C:\LLVM", you might have to add arguments such as these to your compile:

g++ -IC:\LLVM\include -LC:\LLVM\lib -l:LLVMCore.lib source.cpp -o source.exe

As an aside, I’ve not used pre-built LLVM toolchains from any of the Windows installers, so I don’t know if the library files are prefixed with lib. If you see libLLVMCore.lib in your LLVM’s lib directory, you may be able to use -lLLVMCore instead of -l:LLVMCore.lib or -l:libLLVMCore.lib.

Thanks for your responding. I cannot find file LLVMContext.h or LLVMCore.lib in my installation folder. Actually, I don’t know whether the pre-built LLVM is complete. I always get the below error:
builder.c:1:10: fatal error: llvm/IR/LLVMContext.h: No such file or directory

The pre-built LLVM installer for Windows only contains the toolchain parts: clang, lld, compiler-rt libraries, etc. If you need the LLVM libraries, the best way is to build them yourself.

Got it. Thanks you!