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

pkg-config finds mingw *.a library for msvc target #99

Open
nc-x opened this issue Dec 7, 2019 · 5 comments
Open

pkg-config finds mingw *.a library for msvc target #99

nc-x opened this issue Dec 7, 2019 · 5 comments

Comments

@nc-x
Copy link

nc-x commented Dec 7, 2019

Found this because on my windows msvc target, cargo install rustup-toolchain-install-master finds msys2's liblzma.a, converts the name to lzma.lib which is non-existant file, and tries to compile which gives error during linking.

@nirbheek
Copy link

nirbheek commented Dec 13, 2019

This is actually not a problem if your MinGW toolchain uses UCRT, which is the default CRT for the Rust toolchain. So what you actually want to do, instead of #100, is to peek inside the static library and check the CRT used by one of the object files. Same when linking to an import library.

@nc-x
Copy link
Author

nc-x commented Jan 28, 2020

(Sorry for late reply, got busy with stuff :D)

Mingw with UCRT seems to be underdocumented and I can't seem to find any examples of how to use it.

In my mingw-w64 (msys2) installation, I do have a libucrt.a file. But I assume that its for Mingw compiled applications that want to link to ucrt. MSVC afaik cannot link to mingw's *.a files but requires *.lib files.

Do you have any example of how to use ucrt-based-mingw to link *.a to msvc programs?

@nirbheek
Copy link

Mingw with UCRT seems to be underdocumented and I can't seem to find any examples of how to use it.

There's a flag you can pass while building the MinGW/GCC toolchain to make it use UCRT instead of MSVCRT. We do that while building the toolchain for GStreamer's Cerbero build aggregator. We ship a prebuilt toolchain (mingw-6.0.0-gcc-8.2.0) here: https://gstreamer.freedesktop.org/data/cerbero/toolchain/windows/

MSVC afaik cannot link to mingw's *.a files but requires *.lib files.
Do you have any example of how to use ucrt-based-mingw to link *.a to msvc programs?

MSVC can link to both .a and .lib since both are the same format: ar archive. See also: https://mesonbuild.com/FAQ.html#why-does-building-my-project-with-msvc-output-static-libraries-called-libfooa

@nc-x
Copy link
Author

nc-x commented Feb 19, 2020

Due to lack of time, I am unable to work on this. So, if anyone else wants to have a go at this, feel free to. 😄

@luojia65
Copy link

luojia65 commented Sep 11, 2020

Any further works? Our project depends on it. Now I am unable to build GTK on Windows only because of this problem

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

3 participants