如何在Cygwin下运行使用MSYS2构建的可执行文件

时间:2017-04-04 08:57:38

标签: gcc cygwin msys2

使用以下C代码:

int main() {}

我使用gcc -o m2 m2.c在MSYS2下编译。这个gcc是由pacman -S gcc安装的;版本4.9.2目标x86_64-pc-msys。

我将m2.exemsys-2.0.dll复制到另一台安装了Cygwin的PC上的目录中。如果我从命令提示符运行m2.exe它正确执行,但是从Cygwin Bash shell执行我得到错误:

  3 [main] m2 (4552) C:\Temp\m2.exe: *** fatal error - cygheap base mismatch detected - 0x180305408/0x180320400. 
This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version.  The most recent version *should*
reside in x:\cygwin\bin, where 'x' is the drive on which you have
installed the cygwin distribution.  Rebooting is also suggested if you
are unable to find another cygwin DLL.

错误消息令人费解,因为MSYS2根本没有任何cygwin1.dll。

我该如何解决这个问题?显然我不想删除Cygwin安装的cygwin1.dll。

m2可执行文件除了msys-2.0.dll和内置Windows DLL之外没有任何依赖项。 (我和Dependency Walker一起检查过)。它必须是用MSYS2 GCC构建的二进制文件,用于搜索msys-2.0.dll,而是找到已安装的cygwin1.dll。有解决方法吗?

ldd m2.exe的输出是:

    ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x7ffd12740000)
    KERNEL32.DLL => /cygdrive/c/Windows/system32/KERNEL32.DLL (0x7ffd115f0000)
    KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x7ffd0f2b0000)
    msys-2.0.dll => /c/Temp/msys-2.0.dll (0x180040000)

0 个答案:

没有答案