2015-12-09 18 views
0

我在Windows 8系統的新的C++用戶。我已經安裝了MinGW並設置了環境變量。我創建了簡單的hellow世界代碼如下編譯C++與IDE代碼,錯誤在第二時間

#include<iostream> 
    #include<vector> 
    using namespace std; 

    int main(int argc, char **argv) 
    { 
     cout<<"hello world"<<endl; 
     return 0; 
    } 

它運作良好,在第一時間,但是當我做了一些小的修改,例如刪除「你好」,然後生成並重新運行該項目。我發現該程序將繼續運行,沒有結束。命令行不斷顯示:

Current working directory: C:\Users\cr\Documents\project\helloworld\Debug 
    Running program: le_exec.exe ./helloworld 

如果我嘗試重新構建它,它顯示

make.exe[1]: Entering directory 'C:/Users/cr/Documents/project/helloworld' 
    C:/Users/cr/MinGW/bin/g++.exe -c "C:/Users/cr/Documents/project/helloworld/main.cpp" -g -O0 -Wall -o ./Debug/main.cpp.o -I. -I. 
    C:/Users/cr/MinGW/bin/g++.exe -o ./Debug/helloworld @"helloworld.txt" -L. 
    c:/users/cr/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot open output file ./Debug/helloworld.exe: Permission denied 
    collect2.exe: error: ld returned 1 exit status 
    make.exe[1]: *** [Debug/helloworld] Error 1 
    helloworld.mk:78: recipe for target 'Debug/helloworld' failed 
    make.exe[1]: Leaving directory 'C:/Users/cr/Documents/project/helloworld' 
    make.exe: *** [All] Error 2 
    Makefile:4: recipe for target 'All' failed 
    ====1 errors, 0 warnings==== 

我甚至不能刪除可執行文件「HelloWorld.exe的」,因爲它是用在「系統'直到我重新啓動計算機。

更新: 我可以編譯它在命令行:

C:/Users/cr/Documents/project/helloworld>g++ main.cpp -o test.exe 

    C:/Users/cr/Documents/project/helloworld>test.exe 

然後,它會繼續運行,直到我關閉命令行窗口。如果我打開一個新的命令行窗口並再次編譯該文件。沒有問題。

UPDATE2:當我編譯cpp文件,即使文件還沒有被編輯的第二次 問題也會發生。

C:/Users/cr/Documents/project/helloworld>g++ main.cpp -o test.exe 

C:/Users/cr/Documents/project/helloworld>test.exe 
hello world 

C:/Users/cr/Documents/project/helloworld>g++ main.cpp -o test2.exe 

C:/Users/cr/Documents/project/helloworld>test2.exe 

它一直在這裏運行。

+0

*但是當我做了一些小的修改* - 請告訴我們這種「小改」。不要只是描述它。 – PaulMcKenzie

+0

例如,我編輯這一行:COUT << 「Hello World」 的<< ENDL;將它改爲cout <<「world」<< endl; – user5657822

+0

奇怪而奇特。使用調試器是否會給出關於它掛起的提示? – user4581301

回答

0

感謝所有,我與它掙扎了整整一天。問題是反病毒軟件......我將它設置無效,所有的事情做好...... 我不想指出的這個軟件是什麼,只是想給了這個問題一個提醒....