在 2025-01-24 14:45, Werner LEMBERG 写道:
we use mingw to create static LilyPond binaries for Windows (using g++). The default build system is Ubuntu, and everything's fine: `-pthread` is added to the compilation step, and `-pthread -static-libgcc` while linking.However, running exactly the same script on OpenSUSE, 'libwinpthread' is not statically linked into the binary. We solve this locally by adding
The default mingw-w64 GCC on Debian and Ubuntu uses Win32 thread model by
default:
$ x86_64-w64-mingw32-gcc -v 2>&1 | grep '^Thread model:'
Thread model: win32
$ x86_64-w64-mingw32-gcc-posix -v 2>&1 | grep '^Thread model:'
Thread model: posix
Although I am not familiar with OpenSUSE, I suspect their GCC uses POSIX thread
model...?
The difference is that, if GCC has been configured with a mingw target, it has `-pthread` as a
default library [1] [2] and (unless `-static` is specified) prefers a shared library.
The solution is to pass `-no-pthread` to GCC or use a GCC with Win32 thread model; either way, you will have to link against a static winpthread yourself, by passing these options to the linker [3]:
-l:libwinpthread.a -lmsvcrt -lkernel32
[1]
https://github.com/gcc-mirror/gcc/blob/aa73eb97a1e3c84564fa71158d09f9c5582c4d2e/gcc/config/i386/mingw-pthread.h#L21
[2]
https://github.com/gcc-mirror/gcc/blob/aa73eb97a1e3c84564fa71158d09f9c5582c4d2e/gcc/config/i386/mingw32.h#L62
[3] https://github.com/brechtsanders/winlibs_mingw/issues/232#issuecomment-2262666751 -- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
