Page MenuHome GnuPG

"/mkheader.exe: cannot execute binary file: Exec format error" when cross compiling on Windows
Closed, WontfixPublic

Description

I am trying to get the libgpg-error to compile natively (i.e. without resorting to ShiftMediaProject fork) using vcpkg: https://github.com/microsoft/vcpkg/pull/20447

This works fine for native compilation, but not when cross-compiling. Specifically, when targeting arm64-windows, the mkheader.exe is built for the HOST, not BUILD triplet:

"/bin/sh: ./mkheader.exe: cannot execute binary file: Exec format error"

Configure script is run with:

./configure --host=aarch64-pc-mingw32 --build=x86_64-pc-mingw32 --target=x86_64-pc-mingw32 --disable-tests --disable-doc --disable-silent-rules ac_cv_prog_ac_ct_STRIP=: gl_cv_double_slash_root=yes ac_cv_func_memmove=yes gl_cv_host_cpu_c_abi=no lt_cv_deplibs_check_method=pass_all --disable-silent-rules --verbose --enable-shared --disable-static --prefix=/C/vcpkg/installed/arm64-windows/debug '--bindir=${prefix}/../tools/libgpg-error/debug/bin' '--sbindir=${prefix}/../tools/libgpg-error/debug/sbin' '--libdir=${prefix}/lib' '--includedir=${prefix}/../include' '--datarootdir=${prefix}/share/libgpg-error'

BUILD and HOST are detected correctly:

checking build system type... x86_64-pc-mingw32
checking host system type... aarch64-pc-mingw32

Details

Version
1.43

Event Timeline

wrobelda updated the task description. (Show Details)
wrobelda updated the task description. (Show Details)
wrobelda updated the task description. (Show Details)
wrobelda updated the task description. (Show Details)

I tried following the README instructions, but getting:

$ build="$(build-aux/config.guess)"
$ ./configure --prefix=/tmp/gpg-error --host=aarch64-pc-mingw32 --build=$build
$ cd src
$ make gen-posix-lock-obj
gcc -DHAVE_CONFIG_H -I. -I..     -g -O2 -Wall -Wpointer-arith -MT gen-posix-lock-obj.o -MD -MP -MF .deps/gen-posix-lock-obj.Tpo -c -o gen-posix-lock-obj.o gen-posix-lock-obj.c
gen-posix-lock-obj.c:25:3: error: This module may not be build for Windows.
# error This module may not be build for Windows.
  ^
1 error generated.

make: *** [gen-posix-lock-obj.o] Error 1

werner claimed this task.
werner added a subscriber: werner.

GnuPG requires a Unix system to build. We do not support building natively on Windows. Sorry.

FWIW, the gnupg installer comes with dll, header and import files. You may use them.

werner changed the task status from Resolved to Wontfix.Nov 15 2021, 7:40 AM

FWIW, the gnupg installer comes with dll, header and import files. You may use them.

vcpkg is not my personal project, it is a popular dependency manager. I am making an effort to provide support for all platforms supported by vcpkg (Microsoft, Linux, macOS and other), so that users can easily integrate your libraries into their projects.

GnuPG requires a Unix system to build. We do not support building natively on Windows. Sorry.

vcpkg provides an msys2 environment when building natively on Windows and it works for hundreds of automake-based libraries. I don't see why GnuPG would have to be any different? I also managed to build natively on Windows using MSVC, and it wasn't that hard at all, with only a few code changes required [1]. The only problem is *cross-compilation* and this is only because of the requirements of your build system, which I am trying to solve with this task, and one more.

[1] ShiftMediaProject delivers a patch required for each of your libs to compile successfully on Windows with MSVC. See e.g. https://github.com/ShiftMediaProject/libgcrypt/blob/master/SMP/SMP.patch

Please also refer to https://github.com/microsoft/vcpkg/discussions/20755 where we discuss on how to approach GnuPG libraries for a native Windows compilation.

Having all GnuPG libraries in vcpkg would be a tremendous addition. vcpkg provides ports (recipies) for libraries as complex as Qt, fontconfig or ffmpeg and support compiling them natively on Windows. There should be no reason for GnuPG to be left out, with a much simpler code-base and a short list of external dependencies.