Comments (11)
I thought I'd clear up some terminology here so that the error message is not confusing.
MinGW is a port of the GNU toolchain to Windows, and it does not include pkg-config or any other tools. This port is basically unmaintained, and everyone uses MinGW-W64, which is a totally independent effort.
For the tools (including pkg-config), MSYS is one distribution which is shipped with both MinGW and MinGW-W64. In my experience this works quite well but can be difficult to setup.
MSYS2 is a totally separate effort from all these and ships its own toolchains (which it also calls 'MinGW', and is based on MinGW-W64) and its own tools. It is a from-scratch rewrite inspired by Cygwin (but does not use Cygwin), and it really easy to setup and use since it uses the pacman
package manager.
Unfortunately in my experience MSYS2 ships broken versions of tools (including pkg-config). As long as you only use the MSYS2 environment everything works fine, but as soon as you try to mix with outside toolchains (msvc, rustc, etc) or windows tools you quickly run into edge cases. For instance, MSYS does path translation in the environment and on the command-line which MSYS2 does not.
On the Rust side, it might be useful to have something like Python's pathlib
which allows you to translate from Windows to UNIX paths very easily. Then pkg-config-rs would be able to instantiate a PurePath
object and convert to UNIX with the equivalent of PurePath.as_posix()
to ensure that the right kinds of paths are passed in the env to pkg-config.
from pkg-config-rs.
Also, if you only want pkg-config, maybe you can use https://sourceforge.net/projects/pkgconfiglite/ which is a standalone executable. It has worked well for me, but I have not used it extensively.
Ideally someone would reimplement pkg-config in Rust though ;)
from pkg-config-rs.
Hm AFAIK this doesn't attempt to change the env var at all, but I wouldn't be too surprised if pkg-config
-the-program on MinGW behaved differently when invoked from the shell vs from a "native" windows app like a Rust build script.
from pkg-config-rs.
Can you try printing out env::var("PKG_CONFIG_PATH")
in the associated build script and see what pops out?
from pkg-config-rs.
It's indeed behaving different: it's printing the paths as Windows paths (c:\etc) instead of UNIX-style paths. If I set PKG_CONFIG_PATH to such paths myself, pkg-config also fails to find everything.
The pkg-config I have here is the one from msys2.
from pkg-config-rs.
Hm yeah so I know things are really weird on msys2/mingw sometimes, I just never really know when or why. It sounds like our only recourse here is to detect that we'll be calling msys2 and then munge paths manually, but that's sort of crappy :(
from pkg-config-rs.
And not only those, but probably also the paths that pkg-config is returning?
from pkg-config-rs.
Presumably? It's probably easiest just to give a better error and say "install the mingw versions instead of the msys verisons instead"
from pkg-config-rs.
Or that :)
from pkg-config-rs.
Is there a workaround for this issue?
from pkg-config-rs.
@RazrFalcon yes, don't use MSYS2's pkg-config. Use pkgconfiglite which is a standalone executable you can drop anywhere in your PATH
.
from pkg-config-rs.
Related Issues (20)
- Add readme = "README.md" in cargo.toml to have the readme displayed on crates.io HOT 2
- Dependency being constantly rebuilt due to 'env_metadata' being set to 'true' HOT 8
- Should we parse -isystem Cflags? HOT 2
- customized pkg-config is incomplete? HOT 1
- Bug: Missing support for `pkgconf` for Fedora HOT 3
- v0.3.21 raised MSRV to 1.47.0 HOT 4
- Placing pkg-config.exe file to this git if possible HOT 3
- Libraries linked in incorrect order HOT 3
- Incorrect parse result for raw archive path HOT 3
- [Feature Request] Add configurable linking modifiers HOT 6
- `PKG_CONFIG_PATH_FOR_BUILD` env var HOT 4
- Allow disabling pkg-config altogether HOT 7
- static-nobundle option
- Unable to correctly identify a type of Windows static library name, such as `foo.lib` HOT 7
- Cargo build say "library name must not be empty" while using statik(true) HOT 4
- fails with pkgconf 2.0.0 breaking changes HOT 1
- Cannot link static libraries on Windows MinGW because the Libs.private flags are ignored
- Reduce -L flag pollution by resolving -L -l flags to on-disk files
- Rustdoc docs are missing information about environment variables present in README HOT 2
- Cannot link statically against `alsa` library HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pkg-config-rs.