How to include Windows.h with rust bindgen?

963 Views Asked by At

I am starting a new addon for MSFS2020 in rust with the SimConnect SDK written in c++. I am using the bingen crates to create the binding with the SDK.

I need to include Windows.h for the binding to work but I get the following error:

error: header 'Windows.h' does not exist.

If I create a simple c++ project on Visual Studio I can successfully include this header so it's definitely there, but I did not succeed to add it in my rust build.

How can I make my rust build find this header and successfully bind the sdk?

Notes:

  1. I installed the c++ toolchain with Visual Studio 2022
  2. I installed the LLVM toolchain and added the LIBCLANG_PATH to the LLVM bin folder in my environment variables
1

There are 1 best solutions below

0
P.E. Joëssel On

The issue comes from access right rules. Running cargo build as an administrator worked perfectly.