Skip to content

Use pkgconfig for cross-compiling to a -pc-windows-gnu target #1984

Closed
@micolous

Description

@micolous

Using pkgconfig for -pc-windows-gnu targets on non-Windows hosts is currently blocked:

// If we're going to windows-gnu we can use pkg-config, but only so long as
// we're coming from a windows host.
//
// Otherwise if we're going to windows we probably can't use pkg-config.
if target.contains("windows-gnu") && host.contains("windows") {
env::set_var("PKG_CONFIG_ALLOW_CROSS", "1");
} else if target.contains("windows") {
return;
}

It looks like it was originally entirely blocked on Windows in d465f6c

This was then changed to allow it for windows-gnu from a windows host: 43c951f#diff-b088de9b758aec6c173f92e9216ce8ce9597855d542a5d95d14b526d9259f334R140

There's probably a reason for this... but I don't know what, and this was a few years ago... so may not be needed anymore?

If the block on non-Windows hosts was removed:

    if target.contains("windows-gnu") {

Then it's possible to use a vcpkg-provided OpenSSL installation on a non-Windows host:

# the location where you checked out vcpkg to
export VCPKG_ROOT="$HOME/vcpkg"
export PKG_CONFIG_PATH_x86_64_pc_windows_gnu="$VCPKG_ROOT/installed/x64-mingw-static/lib/pkgconfig" 

vcpkg install openssl:x64-mingw-static
cargo build --target x86_64-pc-windows-gnu  ...
wine64 target/x86_64-pc-windows-gnu/debug/...

It may also be possible to use Linux distributions' lib*-mingw-w64 packages (example), if they packaged OpenSSL.

Separately to this, I'm trying to unblock using vcpkg-rs on -pc-windows-gnu targets, but that's blocked on a few other things right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions