3 releases

Uses old Rust 2015

0.1.2 Nov 30, 2022
0.1.1 Feb 15, 2022
0.1.0 Jan 16, 2019

#1612 in Development tools

Download history 20834/week @ 2023-11-24 21136/week @ 2023-12-01 23743/week @ 2023-12-08 20101/week @ 2023-12-15 13431/week @ 2023-12-22 17085/week @ 2023-12-29 17722/week @ 2024-01-05 19247/week @ 2024-01-12 21122/week @ 2024-01-19 22052/week @ 2024-01-26 21618/week @ 2024-02-02 24066/week @ 2024-02-09 22149/week @ 2024-02-16 23914/week @ 2024-02-23 23939/week @ 2024-03-01 13003/week @ 2024-03-08

86,770 downloads per month
Used in 124 crates (via vswhom)

MIT license

28KB
326 lines

vswhom-sys.rs TravisCI Build Status AppVeyorCI Build Status Licence

Pure FFI to Jon Blow's VS discovery script.

Please note that the native code was discovered to cause memory corruption in some cases.

Documentation

Special thanks

To all who support further development on Patreon, in particular:

  • ThePhD
  • Embark Studios
  • Jasper Bekkers

lib.rs:

Pure FFI to Jon Blow's VS discovery script.

The rest of this crate's documentation is copied borderline verbatim from the original C++ source code.

HOW TO USE THIS CODE

The purpose of this file is to find the folders that contain libraries you may need to link against, on Windows, if you are linking with any compiled C or C++ code. This will be necessary for many non-C++ programming language environments that want to provide compatibility.

We find the place where the Visual Studio libraries live (for example, libvcruntime.lib), where the linker and compiler executables live (for example, link.exe), and where the Windows SDK libraries reside (kernel32.lib, libucrt.lib).

We all wish you didn't have to worry about so many weird dependencies, but we don't really have a choice about this, sadly.

I don't claim that this is the absolute best way to solve this problem, and so far we punt on things (if you have multiple versions of Visual Studio installed, we return the first one, rather than the newest). But it will solve the basic problem for you as simply as I know how to do it, and because there isn't too much code here, it's easy to modify and expand.

Here is the API you need to know about:

Call vswhom_find_visual_studio_and_windows_sdk(), look at the resulting paths, then call vswhom_free_resources() on the result.

This file was about 400 lines before we started adding these comments. You might think that's way too much code to do something as simple as finding a few library and executable paths. I agree. However, Microsoft's own solution to this problem, called "vswhere", is a mere EIGHT THOUSAND LINE PROGRAM, spread across 70 files, that they posted to github unironically.

I am not making this up: https://github.com/Microsoft/vswhere

Several people have therefore found the need to solve this problem themselves. We referred to some of these other solutions when figuring out what to do, most prominently ziglang's version, by Ryan Saunderson.

I hate this kind of code. The fact that we have to do this at all is stupid, and the actual maneuvers we need to go through are just painful. If programming were like this all the time, I would quit.

One other shortcut I took is that this is hardcoded to return the folders for x64 libraries. If you want x86 or arm, you can make slight edits to the code below, or, if enough people want this, I can work it in here.

Dependencies