mingw-w64错误ld.exe文件格式无法识别

时间:2019-01-12 09:48:49

标签: mingw-w64 mingw32

安装lat mingw-w64版本8.1.0后,我认为并设置env和Makefile来构建win32 dll(\ i686-8.1.0-win32-dwarf-rt_v6-rev0 \ mingw32 \ bin),我在遇到这些错误无法识别文件格式:

C:/Mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/ i686-w64-mingw32 / lib / libws2_32.a:无法识别文件格式;视为链接脚本

令我惊讶的是,即使以minw-w64格式提供的自己的库也无法识别。

这是makefile:

# MinGW 32 makefile
#
# Change vars MINGW and MINREL in accord to your compiler path/release
#                
MINGW    =C:/Mingw-w64
MINREL   =8.1.0
#
#
CPP      = g++.exe
CC       = gcc.exe
TEMP     =../../temp
OBJ      = $(TEMP)/win32/foo.o $(TEMP)/win32/bar.o 
LINKOBJ  = $(TEMP)/win32/foo.o $(TEMP)/win32/bar.o 
LIBS     = -L "$(MINGW)/lib" -static-libgcc --no-export-all-symbols --add-stdcall-alias $(MINGW)/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/i686-w64-mingw32/lib/libws2_32.a $(MINGW)/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/i686-w64-mingw32/lib/libwinmm.a $(MINGW)/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/lib/gcc/i686-w64-mingw32/$(MINREL)/libstdc++.a

INCS     = -I"$(MINGW)/include" -I"../../../src/sys" -I"../../../src/core" -I"../../../src/lib"
CXXINCS  = -I"$(MINGW)/include" -I"../../../src/sys" -I"../../../src/core" -I"../../../src/lib"
OUTPATH  = ../../bin/Legacy/win32/
DLL      = foo.dll
OUTLIB   = $(OUTPATH)foo.lib
BIN      = $(OUTPATH)$(DLL)
CXXFLAGS = $(CXXINCS) -DBUILDING_DLL=1 -Ofast -pedantic
CFLAGS   = $(INCS) -DBUILDING_DLL=1
RM       = rm -r 

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after

DLLWRAP=dllwrap.exe
DLLTOOL=dlltool.exe
DEFFILE=$(OUTPATH)foo.def

clean: clean-custom
    ${RM} $(OBJ) $(BIN) $(OUTLIB) $(DEFFILE)

$(BIN): $(LINKOBJ)
    $(DLLWRAP) --output-def $(DEFFILE) --driver-name c++ $(LINKOBJ) $(LIBS) -o $(BIN)

和全部输出

dllwrap.exe --output-def ../../bin/Legacy/win32/foo.def --driver-name c++ ../../temp/win32/snap_msgsock.o ../../temp/win32/snap_sysutils.o ../../temp/win32/snap_tcpsrvr.o ../../temp/win32/snap_threads.o ../../temp/win32/s7_client.o ../../temp/win32/s7_isotcp.o ../../temp/win32/s7_micro_client.o ../../temp/win32/s7_partner.o ../../temp/win32/s7_peer.o ../../temp/win32/s7_server.o ../../temp/win32/s7_text.o ../../temp/win32/foo.o -L "C:/Mingw-w64/lib" -static-libgcc --no-export-all-symbols --add-stdcall-alias C:/Mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/i686-w64-mingw32/lib/libws2_32.a C:/Mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/i686-w64-mingw32/lib/libwinmm.a C:/Mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/libstdc++.a -o ../../bin/Legacy/win32/foo.dll
C:/mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe:C:/Mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/**i686-w64-mingw32/lib/libws2_32.a: file format not recognized; treating as linker script**
C:/mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe:C:/Mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/i686-w64-mingw32/lib/libws2_32.a:1: syntax error
collect2.exe: error: ld returned 1 exit status
C:\mingw-w64\i686-8.1.0-win32-dwarf-rt_v6-rev0\mingw32\bin\dllwrap.exe: no export definition file provided.
Creating one, but that may not be what you want
C:\mingw-w64\i686-8.1.0-win32-dwarf-rt_v6-rev0\mingw32\bin\dllwrap.exe: c++ exited with status 1
mingw32-make: *** [Makefile:39: ../../bin/Legacy/win32/foo.dll] Error 1

0 个答案:

没有答案