2011-11-30 94 views
0

看到我有這樣的代碼由MinGW編譯器生成的二進制文件將在沒有Mingw的機器上運行?

#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運行其上的其他窗口機二進制它不run..says cygwin.dll缺少類似的東西,錯誤出現

+0

您可能會遇到pthreads問題...請參閱http://stackoverflow.com/questions/5057192/threaded-c-programs-in-mingw –

回答

4

如果我記住它應該只依賴於Microsoft CRT(msvcrt.dll,可能是Windows上最老的版本之一)和其他系統標準DLL(kernel32.dll & co。),但你可以通過檢查您的可執行文件爲Dependency Walker

+0

+1是的,同意此答案。 – Steve

+2

它的依賴是kernal32和msvcrt.dll和PTHREADGC2.DLL在其他系統中找不到該PTHREADGC2.DLL,因此無法正常工作 –

+0

然後,您只需使用您的應用程序重新分發'ptheradgc2.dll'。您也可以靜態鏈接到相應的靜態庫(如果可用)。 –