Here is an example demonstrating a Visual Studio 2017 solution that introduces a Rust static library.
If you want to make this youself, you can start by following "A little Rust with your C".
Make sure to grab the cbindgen.toml template along the way.
You must use crate-type = ["staticlib"]
instead of cdylib
for this, since Visual Studio will statically link for you.
Once you're done, create a new Visual C++ project, mine was the 'Visual C++ > Empty Project' template.
Set the following settings in your project properties...
-
C/C++ > General > Additional Include Directories:
$(ProjectDir)\YOUR_RUST_CRATE_NAME_HERE;%(AdditionalIncludeDirectories)
-
Linker > General > Additional Library Directories:
$(ProjectDir)\YOUR_RUST_CRATE_NAME_HERE\target\debug;%(AdditionalLibraryDirectories)
-
Linker > Input > Additional Dependencies:
YOUR_RUST_CRATE_NAME_HERE.lib;ws2_32.lib;userenv.lib;bcrypt.lib;%(AdditionalDependencies)
- And I couldn't tell ya why the heck
ws2_32.lib;userenv.lib;bcrypt.lib;
are needed to compile :^)
Hope this helps for people who are relatively n00bies with Visual Studio :D