为什么用64位MinGW g ++编译的程序不能在我的64位PC上运行?

时间:2015-05-21 22:51:49

标签: gcc cygwin mingw x86-64

我在64位Windows 8.1上使用Cygwin。

我想在Cygwin环境中制作本机Windows可执行文件(即我不想处理cygwin dll问题)。我看到Cygwin有minGW包,所以我下载了

  • 的i686-PC-的mingw32-GCC
  • x86_64的-W64-的mingw32-GCC

包。从this帖子开始,我收集了i686,其中一个是32位,x86_64是64位。

我使用了i686和x86_64版本的g ++来编译一个简单的hello world程序,并且编译时都没有错误。

i686编译的可执行文件按预期工作。

我的问题:当我尝试运行x86_64版本编译的可执行文件时,我收到一个Windows错误框,说“#34;应用程序无法正常启动(0x000007b)”。单击“确定”关闭应用程序。"

我很困惑。为什么32位编译器工作且64位编译器不能在我的系统上运行?

如果它有帮助,这里是我调用它时x86_64编译器正在做的事情

$ x86_64-w64-mingw32-g++ test.cpp -o dd -v
Using built-in specs.

COLLECT_GCC=x86_64-w64-mingw32-g++

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe

Target: x86_64-w64-mingw32

Configured with: /cygdrive/i/szsz/tmpp/cygwin64/mingw64-x86_64/mingw64-            x86_64-gc                                                                                                                                                              c-4.9.2-1.x86_64/src/gcc-4.9.2/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64                                                                                                                                                              /mingw64-x86_64/mingw64-x86_64-gcc-4.9.2-1.x86_64/src/gcc-4.9.2 --prefix=/usr --                                                                                                                                                              exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/                                                                                                                                                              mingw64-x86_64-gcc --htmldir=/usr/share/doc/mingw64-x86_64-gcc/html -C --build=x                                                                                                                                                              86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-w64-mingw32 --without-li                                                                                                                                                             biconv-prefix --without-libintl-prefix --with-sysroot=/usr/x86_64-w64-mingw32/sy                                                                                                                                                              s-root --with-build-sysroot=/usr/x86_64-w64-mingw32/sys-root --disable-multilib                                                                                                                                                               --disable-win32-registry --enable-languages=c,ada,c++,fortran,lto,objc,obj-c++ -                                                                                                                                                              -enable-fully-dynamic-strings --enable-graphite --enable-libgomp --enable-libqua                                                                                                                                                              dmath --enable-libquadmath-support --enable-libssp --enable-version-specific-run                                                                                                                                                             time-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-c                                                                                                                                                              loog-include=/usr/include/cloog-isl --with-system-zlib --libexecdir=/usr/lib

Thread model: win32

gcc version 4.9.2 (GCC)

COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march                                                                                                                                                              =x86-64'
 /usr/lib/gcc/x86_64-w64-mingw32/4.9.2/cc1plus.exe -quiet -v -U_REENTRANT test.c                                                                                                                                                               pp -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -version                                                                                                                                                               -o /tmp/ccKIncrs.s

GNU C++ (GCC) version 4.9.2 (x86_64-w64-mingw32)
    compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p                                                                                                                                                              11, MPC version 1.0.3

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/sys-  root/usr/local/inclu                                                                                                                                                              de"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-  mingw32/4.9.2/../../../.                                                                                                                                                              ./x86_64-w64-mingw32/include"

\#include "..." search starts here:

\#include <...> search starts here:
 /usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++
 /usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/x86_64-w64-mingw32
 /usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/backward
 /usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include
 /usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include-fixed
 /usr/x86_64-w64-mingw32/sys-root/mingw/include
  End of search list.

GNU C++ (GCC) version 4.9.2 (x86_64-w64-mingw32)
    compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p                                                                                                                                                              11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

Compiler executable checksum: aee7f7b7ca14852762daf4c41db46c26

COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march                                                                                                                                                              =x86-64'
 /usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64- mingw32/bin/as.exe                                                                                                                                                               -v -o /tmp/ccSHmwxw.o /tmp/ccKIncrs.s
GNU assembler version 2.25.51 (x86_64-w64-mingw32) using BFD version (GNU  Binuti                                                                                                                                                               ls) 2.25.51.20150320

COMPILER_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/:/usr/lib/gcc/x86_64-w64-min                                                                                                                                                              gw32/4.9.2/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/4.9                                                                                                                                                              .2/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../..                                                                                                                                                             /../../x86_64-w64-mingw32/bin/

LIBRARY_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/:/usr/lib/gcc/x86_64-w64- ming                                                                                                                                                              w32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/:/usr/x86_64-w64-mingw32/sys                                                                                                                                                              -root/mingw/lib/../lib/:/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64                                                                                                                                                             -w64-mingw32/lib/:/usr/x86_64-w64-mingw32/sys-root/mingw/lib/
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '-   march                                                                                                                                                                =x86-64'
 /usr/lib/gcc/x86_64-w64-mingw32/4.9.2/collect2.exe -plugin      /usr/lib/gcc/x86_64-                                                                                                                                                                 w64-mingw32/4.9.2/cyglto_plugin.dll -plugin-opt=/usr/lib/gcc/x86_64-w64-mingw32/                                                                                                                                                                4.9.2/lto-wrapper.exe -plugin-opt=-fresolution=/tmp/ccaaJ5U7.res -plugin-opt=-pa                                                                                                                                                              ss-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through                                                                                                                                                              =-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex                                                                                                                                                               -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-                                                                                                                                                              opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass                                                                                                                                                              -through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-throug                                                                                                                                                              h=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -                                                                                                                                                              plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=                                                                                                                                                              /usr/x86_64-w64-mingw32/sys-root -m i386pep -Bdynamic -o dd.exe /usr/x86_64-w64-                                                                                                                                                              mingw32/sys-root/mingw/lib/../lib/crt2.o /usr/x86_64-w64-mingw32/sys-root/mingw/                                                                                                                                                              lib/../lib/crtbegin.o -L/usr/lib/gcc/x86_64-w64-mingw32/4.9.2 -L/usr/lib/gcc/x86                                                                                                                                                              _64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib -L/usr/x86_64-w6                                                                                                                                                              4-mingw32/sys-root/mingw/lib/../lib -L/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../.                                                                                                                                                                ./../../x86_64-w64-mingw32/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib /tmp                                                                                                                                                              /ccSHmwxw.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladv                                                                                                                                                              api32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex                                                                                                                                                               -lmsvcrt /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/default-manifest.o /                                                                                                                                                              usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/crtend.o
编辑:做了一些测试。当我创建一个比hello world更复杂的程序时(我使用了#include),i686版本的可执行文件失败了,因为它缺少了一些与GCC相关的dll。当我添加-static-libgcc -static-libstdc ++时,两个版本的编译器都可以工作。

这使我得出结论与我的链接器和DLL混乱的东西。我对此并不太了解:(

0 个答案:

没有答案