Fork me on GitHub

ClangSharp - C# and .NET Clang bindings

ClangSharp are strongly-typed safe C# bindings for LibClang C bindings from the Clang project. ClangSharp is self hosting and generates itself from Libclang header files.

ClangSharp generated interfaces are one single C# file -- Example: ClangSharp Source

Windows users (includes LibClang x86/x64 DLLs): ClangSharp 3.6 on Nuget

Also checkout LLVMSharp - LLVM Bindings for C# (generated using ClangSharp PInvoke Generator)

Building ClangSharp

ClangSharp runs (and hence requires) either Mono or Microsoft .NET; and at least Clang to be built as a shared library (this is default on Linux and Windows).

These instructions assume you are familiar with building LLVM and/or building Clang as Shared Libraries.

 

Using Mono (on Linux, MacOSX):
$ git clone http://github.com/mjsabby/ClangSharp
$ cd ClangSharp
$ chmod +x build.sh
$ ./build.sh /path/to/libclang.so /path/clang/include

 

Using Microsoft.NET (on Windows):
:> git clone http://github.com/mjsabby/ClangSharp
:> cd ClangSharp
:> build.bat c:\path\libclang.dll c:\path\to\clang\include

ClangSharp PInvoke Generator

ClangSharp PInvoke Generator is ClangSharp's self-hosting mechanism that generates ClangSharp using ClangSharp. It is also a great example of using ClangSharp (to generate C# PInvoke interfaces).

License

Copyright (C) 2015 Mukul Sabharwal (@mjsabby)
Distributed under the University of Illinois/NCSA Open Source License, the same as Clang and LLVM.