[英]Compile c++ code with IDE, error at the second time
我是Windows 8系統中的c ++新用戶。 我已經安裝了MinGW並設置了環境變量。 我創建如下最簡單的世界代碼
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char **argv)
{
cout<<"hello world"<<endl;
return 0;
}
第一次時它運行良好,但是當我進行一些小修改時,例如刪除“ hello”,然后再次構建並運行該項目。 我發現該程序將繼續運行而沒有結束。 命令行不斷顯示:
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
它一直在這里運行。
謝謝大家,我整整苦了一天。 問題是防病毒軟件……我將其設置為非活動狀態,並且一切正常……我不想指出該軟件是什么,而只是想提醒這個問題。 ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.