簡體   English   中英

無法在 64 位系統上構建 32 位二進制文件

[英]Can't build 32-bit binaries on a 64 bit system

介紹

雖然我能夠為我的 64 位 windows 系統構建二進制文件,但我無法找到生成 32 位二進制文件的方法,盡管我已經嘗試了很多東西,但我仍然會遇到很多錯誤。 具體來說,我正在嘗試的是在 32 位系統的wincon文件夾下構建PDCurses-3.9 (專用於我試圖維護的這個unicurses庫)

但到目前為止我所嘗試的只給了我錯誤

  • 主要是我所做的唯一重大更改是將-m32標志添加到wincon/Makefile ,如下所示:
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 專業版 64 位 | 英特爾(R) 酷睿(TM) i7-6700 中央處理器

> 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

結局

一般來說,我已經嘗試過更改 makefile 但我對這些東西有點菜鳥,所以我沒有成功 [...]有什么想法嗎? 提前致謝

我不確定-m32是否真的能夠在 Windows 上切換目標。如果它有任何工作的機會,你實際上需要有一個針對你系統上32 位的編譯器,而x86_64-w64-mingw32不是它,你可能想要i686-w64-mingw32並且它可能在你的 msys 文件夾中的 mingw32 中?

如果構建腳本調用 gcc.exe 時沒有任何類型的目標前綴,那么正確的編譯器需要位於您的 %path% 中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM