在 2022-06-15 07:11, Allen Hewes 写道:
Hi,

I am getting a redefinition of 'vsnprintf' when trying to build a 32-bit gcc 
9.5.0 (sjlj/posix) with mingw-builds:


It looks like configure thinks `vsnprintf()` was not available and attempted to provide one from libiberty.


C:\mingw950\i686-950-posix-sjlj-rt_v1000-rev0\mingw32\bin\ld.exe: 
C:/mingw950/i686-950-posix-sjlj-rt_v1000-rev0/mingw32/mingw/lib/../lib/libmsvcrt.a(lib32_libmsvcrt_extra_a-_vscprintf.o):_vscprintf.c:(.text+0xc6):
 undefined reference to `_imp__GetModuleHandleW@4'
C:\mingw950\i686-950-posix-sjlj-rt_v1000-rev0\mingw32\bin\ld.exe: 
C:/mingw950/i686-950-posix-sjlj-rt_v1000-rev0/mingw32/mingw/lib/../lib/libmsvcrt.a(lib32_libmsvcrt_extra_a-_vscprintf.o):_vscprintf.c:(.text+0xde):
 undefined reference to `_imp__GetProcAddress@8'
collect2.exe: error: ld returned 1 exit status



Please have a look at 'gcc/config/i386/mingw32.h'. If after `-lmoldname -lmingwex -lmsvcrt` there is no `-lkernel32`, you probably need the attached patch.


--
Best regards,
LIU Hao
From 850533ab160ef40eccfd039e1e3b138cf26e76b8 Mon Sep 17 00:00:00 2001
From: Jonathan Yong <10wa...@gmail.com>
Date: Sat, 30 May 2020 03:53:16 +0000
Subject: [PATCH] gcc/config/i386/mingw32.h: Ensure `-lmsvcrt` precede
 `-lkernel32`

This is necessary as libmsvcrt.a is not a pure import library, but
also contains some functions that invoke others in KERNEL32.DLL.

gcc/
        * config/i386/mingw32.h (REAL_LIBGCC_SPEC): Insert -lkernel32
        after -lmsvcrt. This is necessary as libmsvcrt.a is not a pure
        import library, but also contains some functions that invoke
        others in KERNEL32.DLL.

Signed-off-by: Liu Hao <lh_mo...@126.com>
Signed-off-by: Jonathan Yong <10wa...@gmail.com>
---
 gcc/config/i386/mingw32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index 1bbabfe8bed5..321c30e41cc5 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -165,7 +165,7 @@ along with GCC; see the file COPYING3.  If not see
 #define REAL_LIBGCC_SPEC \
   "%{mthreads:-lmingwthrd} -lmingw32 \
    " SHARED_LIBGCC_SPEC " \
-   -lmoldname -lmingwex -lmsvcrt"
+   -lmoldname -lmingwex -lmsvcrt -lkernel32"
 
 #undef STARTFILE_SPEC
 #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
-- 
2.36.1

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to