Cannot build qemu utils (qemu-img.exe, qemu-edid.exe, qemu-io.exe) statically with MSYS64 on Windows because intl and iconv libs are not loaded
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Expired
|
Undecided
|
Unassigned |
Bug Description
Using MSYS2 and mingw32 instructions from https:/
Steps to reproduce the issue:
1. Install MSYS2 on a Windows 10 x64 box
2. Install required mingw64 toolchain: pacman -S base-devel mingw-w64-
3. clone qemu
4. Run configure for static build for the tools only
./configure --disable-user --disable-system --disable-docs --enable-tools --disable-
# I had to remove sheepdog, capstone and guest agent because other errors popped out, but let's not go in the rabbit hole.
5. Run 'make -j'. the following errors appeared, signaling that intl lib is not loaded. If I add intl lib, iconv lib needs to be loaded too.
make: *** [/home/
make: *** Waiting for unfinished jobs....
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
C:/msys64l/
Patch to fix the issue (added intl and iconv to the libs):
diff --git a/configure b/configure
index 30aad233d1.
--- a/configure
+++ b/configure
@@ -920,7 +920,7 @@ if test "$mingw32" = "yes" ; then
DSOSUF=".dll"
# MinGW needs -mthreads for TLS and macro _MT.
QEMU_
- LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
+ LIBS="-lwinmm -lws2_32 -liphlpapi -lintl -liconv $LIBS"
write_
if compile_prog "" "-liberty" ; then
LIBS="-liberty $LIBS"
description: | updated |
summary: |
Cannot build qemu utils (qemu-img.exe, qemu-edid.exe, qemu-io.exe) - statically with MSYS2 on Windows + statically with MSYS2 on Windows because intl and iconv libs are not + loaded |
tags: | added: mingw32 msys windows |
summary: |
Cannot build qemu utils (qemu-img.exe, qemu-edid.exe, qemu-io.exe) - statically with MSYS2 on Windows because intl and iconv libs are not + statically with MSYS64 on Windows because intl and iconv libs are not loaded |
I think this is probably a bug in the packaging of glib. What does "pkg-config --static --libs glib-2.0" say? If it doesn't say that you need to add -lintl -liconv to do a static link against glib, then that's a glib packaging bug. If it does say you need those flags, then we have a QEMU configure script bug where we're failing to get the link line correct (but we should fix it by using pkg-config correctly, not by manually adding the libraries to the LIBS variable).
I'm not sure how much this applies to Windows, but in general we don't support static linking for anything except the linux-user executables, largely because so often the libraries we depend on don't ship with correct pkg-config data for how to statically link them.