cloudflare / boringtun

Userspace WireGuard® Implementation in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C++ link

P45H3 opened this issue · comments

commented

Im build boringtun as x64-32 msvc and get boringtun.rlib. How to link boringtun to c++ proj and use ffi boringtun header?

RLIB extension stands for Rust library. To build MSVC static libraries (also statically linked to MSVC runtime), you need to do the following:

  1. Add the lines below to the .cargo/config
[target.x86_64-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]

[target.i686-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]
  1. Add the following at the bottom of boringtun/Cargo.toml
[lib]
crate-type = ["staticlib"]
bench = false
  1. And finally, build the boringtun libraries to get boringtun.lib for MSVC platforms:
cargo build --target=i686-pc-windows-msvc --lib
cargo build --target=i686-pc-windows-msvc --lib --release
cargo build --target=x86_64-pc-windows-msvc --lib
cargo build --target=x86_64-pc-windows-msvc --lib --release
commented

Thank you) I builded it.
Is there an example of using a wireguard_ffi in a C++ program? (Creating a tunnel and wrapping traffic in it?)

Boringtun does not currently creating a tun interface on windows. Hopefully we can eventually add support via Wintun, but there are a number of difficulties in doing so.

@P45H3 I'm going to close this ticket since the original issue has been resolved, however if you still have questions, feel free to keep asking on this ticket.