我尝试使用gcc(5.3.0)在MSYS2(diff
)中的64位Windows 7上编译带有混合Fortran / C代码的DLL。我想把它编译成32位。 (如果我省略msys2-x86_64-20160205
标志并将其编译为64位,它就可以正常工作。)
由于对我这样的事情缺乏经验,我可能犯了一些非常愚蠢的错误......所以我提前道歉!
我似乎遇到的砖墙如下。
我已经成功(我认为)安装了32位工具链,但是当我运行Makefile时,它似乎无法找到它。
任何人都可以帮我指出正确的方向吗?
写得不好的Makefile:
-m32
正在运行FC=gfortran -g -m32
CC=g++ -g -m32
DLL_SRC_DIR=.
BUILD_DIR=build
all:
$(FC) -c $(DLL_SRC_DIR)/fdll.f90 -o $(BUILD_DIR)/fdll.o
$(CC) -c -DBUILDING_C_DLL $(DLL_SRC_DIR)/cdll.cpp -o $(BUILD_DIR)/cdll.o
$(CC) -shared -o $(BUILD_DIR)/libcdll.dll $(BUILD_DIR)/cdll.o $(BUILD_DIR)/fdll.o -Wl,--out-implib,$(BUILD_DIR)/libcdll.a,--output-def,$(BUILD_DIR)/libcdll.def -lgfortran
/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio\ 12.0/VC/BIN/lib /MACHINE:x86 /DEF:$(BUILD_DIR)\\libcdll.def /OUT:$(BUILD_DIR)\\libcdll.lib
clean:
rm -f $(BUILD_DIR)/*
:
make
安装32位工具链:
$ make
gfortran -g -m32 -c ./fdll.f90 -o build/fdll.o
g++ -g -m32 -c -DBUILDING_C_DLL ./cdll.cpp -o build/cdll.o
g++ -g -m32 -shared -o build/libcdll.dll build/cdll.o build/fdll.o -Wl,--out-implib,build/libcdll.a,--output-def,build/libcdll.def -lgfortran
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgfortran.dll.a when searching for -lgfortran
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgfortran.a when searching for -lgfortran
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgfortran.a when searching for -lgfortran
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgfortran.dll.a when searching for -lgfortran
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgfortran.a when searching for -lgfortran
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lgfortran
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libstdc++.dll.a when searching for -lstdc++
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libstdc++.a when searching for -lstdc++
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libstdc++.a when searching for -lstdc++
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libstdc++.dll.a when searching for -lstdc++
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libstdc++.a when searching for -lstdc++
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lstdc++
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lgcc
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lmsys-2.0
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -ladvapi32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lshell32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -luser32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lkernel32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-msys/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
make: *** [Makefile:12: all] Error 1
答案 0 :(得分:1)
似乎没有人想发布我们在问题评论中发现的答案,所以我发布它只是为了解决问题。
我需要使用C:\msys64\mingw32.exe
可执行文件启动shell。有关更多详细信息,请参阅注释。