Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a pre-built clang library for Windows? [closed]

Tags:

windows

dll

clang

I am developing a tool using the clang library on Linux and I would like to port this tool to Windows.

On Linux, I can install Clang from the LLVM repositories using apt-get clang-6.0-dev and simply link my tool with -lclang. I do not need to compile LLVM and Clang myself.

Is there a way to do something similar on Windows, or do I need to compile the Clang library myself?

All of the Clang-related posts I could find are about using clang as a tool, not as a library.

I have installed the pre-build executables for Clang and LLVM from the LLVM website, and these work nicely in combination with mingw. However, the download for Windows does not seem to include the Clang library as a separate file (DLL), and linking with -lclang results in a linker error.

If there is no pre-built library for Windows, what is the best way to proceed, preferably using mingw and not MSVC?

like image 904
ygramoel Avatar asked Jul 12 '18 15:07

ygramoel


People also ask

Is there Clang for Windows?

On Windows, it's easy to install the Clang tools. Just grab the “Clang compiler for Windows,” an optional component of the “Desktop development with C++” workload. This will install everything you need to develop with Clang on Windows. You can also install your own copy of Clang/LLVM or even build it from source.

Where is Clang installed on Windows?

Use the default install location: C:\Program Files (x86)\LLVM and complete the installation. clang++.exe should be located in C:\Program Files (x86)\LLVM\bin , but should NOT be in your system path.

What is C++ Clang Tools for Windows?

The Clang tool is a front end compiler that is used to compile programming languages such as C++, C, Objective C++ and Objective C into machine code. Clang is also used as a compiler for frameworks like OpenMP, OpenCL, RenderScript, CUDA and HIP.


1 Answers

There are pre-built LLVM/clang binaries on Zig's github page:
https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows

You can find libclang.dll in the bin folder.

The currently available versions are:

  • llvm+clang-6.0.0-win64-msvc-release.tar.xz
  • llvm+clang-7.0.0-win64-msvc-release.tar.xz
  • llvm+clang-8.0.0-win64-msvc-release.tar.xz
  • llvm+clang-9.0.0-win64-msvc-release.tar.xz
  • llvm+clang+lld-10.0.0-x86_64-windows-msvc-release-mt.tar.xz

There are also detailed build instructions, here.

like image 67
valiano Avatar answered Sep 28 '22 11:09

valiano