Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on Windows using vcpkg #143

Open
CGMossa opened this issue Dec 2, 2023 · 4 comments
Open

Build on Windows using vcpkg #143

CGMossa opened this issue Dec 2, 2023 · 4 comments

Comments

@CGMossa
Copy link

CGMossa commented Dec 2, 2023

I've finally got this to work on the recommended rust toolchain. Previously discussed here #53 and #75.
On Windows, we are recommended to use stable-msvc / nightly-msvc.

You can install that using scoop, or manually here https://github.com/microsoft/vcpkg#quick-start-windows

scoop install vcpkg

Then, you set the following environment variables globally

VCPKG_DEFAULT_TRIPLET=x64-windows-static-md
VCPKG_INSTALLED_DIR=C:/Users/minin/scoop/apps/vcpkg/current/installed
LIB=%VCPKG_INSTALLED_DIR%/%VCPKG_DEFAULT_TRIPLET%/lib
INCLUDE=%VCPKG_INSTALLED_DIR%/%VCPKG_DEFAULT_TRIPLET%/include

That's it, this made my test project compile just fine.

Use of these environment variables is described in https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#path_and_environment, and https://stackoverflow.com/questions/20483619/lib-vs-libpath-environment-variables-difference-for-ms-visual-c-c,

You can choose different triplet, see vckpkg help triplet, but x64-windows-static-md is recommended by vcpkg-rs.

Even the blas-example works with this!

vcpkg would also (presumably) make CMake work on Windows.

@GuillaumeGomez
Copy link
Owner

Nice. Do you want to update the README documentation to mention it? Or update the crate documentation in lib.rs?

@CGMossa
Copy link
Author

CGMossa commented Dec 2, 2023

With your blessing I can do either or both :)
I'm also exploring this option a bit more. Right now, I find the scoop lacking. I've made one PR over there to help out (with one line also :( )

@GuillaumeGomez
Copy link
Owner

Let's go for both then please. :)

@CGMossa
Copy link
Author

CGMossa commented Dec 3, 2023

I've made pijul compile on Windows as well, with these instructions:

set VCPKG_DEFAULT_TRIPLET=x64-windows-static-md
vcpkg install openssl zstd pkgconf
set LIB=C:\dev\vcpkg\installed\x64-windows-static-md\lib
set PKG_CONFIG_PATH=C:\dev\vcpkg\installed\x64-windows-static-md\lib\pkgconfig

Apparently, if pkgconfig is used then the last thing has to be set.
https://stackoverflow.com/questions/74498102/why-doesnt-my-windows-environment-properly-install-external-c-libraries
These instructions are very much scattered. I'm almost sure that I got the system figured out.
It cannot be done with using RUSTCWRAPPER="vcpkg env" if you're wondering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants