【问题标题】:Binary generated by MinGW compiler will work on the machine without Mingw?MinGW 编译器生成的二进制文件可以在没有 Mingw 的机器上运行吗?
【发布时间】:2011-11-30 17:03:21
【问题描述】:

看到我有类似的代码

#include<stdio.h>
#include<pthread.h>
#include<string.h>

void* thread_function(void)
{
  printf ("This is thread %d \n",pthread_self())
}
int main(int argc,char *argv[])
{
    pthread_t thread_id[argc-1];
    int i;
    int status;
    printf("argc is %d ",argc-1);
   for(i=0;i<argc-1;i++)
    {
    pthread_create (&thread_id[i], NULL , &thread_function, NULL);
    }  

    for(i=0;i<argc-1;i++)
        pthread_join(thread_id[i],NULL);   
}

现在我已经通过 MinGw 编译器 gcc.exe 4.6.1 编译它并得到 a.exe 现在我想问你 这个 a.exe 是否可以在其他 Windows 机器上工作没有安装 MinGW?

编辑: 当我通过 Cygwin 编译器编译这段代码并在没有 cygwin 的其他 Windows 机器上运行它的二进制文件时,它不会运行..说 cygwin.dll 缺少类似错误的东西

【问题讨论】:

标签: c windows mingw


【解决方案1】:

如果我没记错的话,它应该只依赖于 Microsoft CRT(msvcrt.dll,可能是 Windows 上可用的最旧版本之一)和其他系统标准 dll(kernel32.dll & co.),但您可以轻松检查通过使用Dependency Walker 检查您的可执行文件,您可以自行完成。

【讨论】:

  • 它的依赖是kernal32和msvcrt.dll和PTHREADGC2.DLL,其中PTHREADGC2.DLL在其他系统上没有找到所以不能工作
  • 那么你只需要在你的应用程序中重新分配ptheradgc2.dll。您还可以静态链接到相应的静态库(如果可用)。
猜你喜欢
  • 1970-01-01
  • 2021-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-02
  • 2010-12-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多