无法在 64 位系统上生成 32 位二进制文件



简介

虽然我能够为我的64位windows系统构建二进制文件,但我无法找到生成32位二进制文件的方法,尽管我尝试了很多方法,但仍然会遇到很多错误特别是我正在尝试的是在wincon文件夹下为32位系统构建PDCurses-3.9(专用于我试图维护的这个unicurses库)

但到目前为止,我所尝试的只是错误

  • 主要是我所做的唯一重大更改是将-m32标志添加到"CCD_ 3">如下所示:
ifeq ($(DEBUG),Y)
CFLAGS  = -g -Wall -DPDCDEBUG
LDFLAGS = -g
else
CFLAGS  = -m32 -O2 -Wall # <-- 
LDFLAGS = -m32           # <--
endif
  • 但当我尝试make -f Makefile DLL=Y时,我最终得到的是:
...
windres -i ../common/pdcurses.rc pdcurses.o
gcc -Wl,--out-implib,pdcurses.a -shared -o pdcurses.dll addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o clear.o color.o delch.o deleteln.o getch.o getstr.o getyx.o inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o keyname.o mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o touch.o util.o window.o debug.o pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o pdcutil.o pdcurses.o
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot export COLORS: symbol not found
... 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `addch.o' is incompatible with i386:x86-64 output
...
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: color.o:color.c:(.text+0x670): undefined reference to `_getenv'
... 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: pdcutil.o:pdcutil.c:(.text+0x4a): undefined reference to `__imp__GetTickCount@0'
collect2.exe: error: ld returned 1 exit status
make: *** [pdcurses.dll] Error 1

^=许多

系统信息

Windows 10 Pro 64位|英特尔(R)酷睿(TM)i7-6700 CPU

> gcc --version
gcc (Rev5, Built by MSYS2 project) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-pc-mingw32

Outro

一般来说,我已经尝试过更改makefile,但当涉及到这些东西时,我有点迟钝,所以我没有成功[…]有什么想法吗?提前感谢

我不确定-m32是否真的能够在Windows上切换目标。如果它有任何工作的机会,你实际上需要一个针对系统上32位的编译器,而x86_64-w64-mingw32不是,你可能想要i686-w64-mingw32,它可能在你的msys文件夹中的mingw32中?

如果构建脚本在没有任何目标前缀的情况下调用gcc.exe,那么正确的编译器需要位于%path%中的第一个。

最新更新