2015-12-09 25 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

感谢所有,我与它挣扎了整整一天。问题是反病毒软件......我将它设置无效,所有的事情做好...... 我不想指出的这个软件是什么,只是想给了这个问题一个提醒....