rvenner
rvenner

Reputation: 31

How to make Libsodium Available to Rust on Windows (beginner's guide)?

I can't find any clear answers to this.

I'm a beginning Rust programmer (read the book, wrote and compiled simple programs). Almost no knowledge of C/C++. The platform is Windows 7 64-bit. Rust stable (managed by Rustup) and I'd prefer the GNU ABI.

I'm compiling a git repository that requires libsodium, and compiling exits with an error that libsodium is not found.

Is there a step-by-step guide to installing libsodium for my Rust setup? The documentation that I've found assumes a bit too much about the knowledge of the reader.

I did manage to compile and "install" libsodium in MSYS2, but then Rust (which I can't see from inside MSYS2) still can't find it.

What is the better way to do this?

Upvotes: 3

Views: 1338

Answers (1)

pengowen123
pengowen123

Reputation: 1017

When I try to build sodiumoxide, it fails because pkg-config cannot find libsodium. To install it, go here and download the latest version named libsodium-x.x.x-mingw.tar.gz, where x.x.x is the version number. Extract it using a tool such as 7-zip, and copy libsodium-win64 (or win32 for 32-bit systems) to a place of your choice.

For pkg-config to find libsodium, you need to copy libsodium.pc from libsodium-win64/lib/pkgconfig (or win32) to somewhere pkg-config will look. To find where pkg-config looks, run this command:

pkg-config --variable pc_path pkg-config

Copy libsodium.pc to one of the directories listed. If no directories are listed, you must add a directory (see this answer). pkg-config should now be able to find libsodium, so you can build libraries that require it.

Upvotes: 6

Related Questions