用IDE编译c++代码,第二次出现错误
Compile c++ code with IDE, error at the second time
我是Windows8系统中的新c++用户。我已经安装了MinGW并设置了环境变量。我创建了如下中最简单的hellow-world代码
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char **argv)
{
cout<<"hello world"<<endl;
return 0;
}
它在第一次运行时效果很好,但当我做一些小的修改时,例如删除"hello",然后重新构建并运行项目。我发现这个程序会一直运行下去。命令行不断显示:
Current working directory: C:UserscrDocumentsprojecthelloworldDebug
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
然后它将一直运行,直到我关闭命令行窗口。如果我打开一个新的命令行窗口并再次编译该文件。没有问题。
更新2:当我第二次编译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
它一直在这里运行。
谢谢大家,我为此奋斗了一整天。问题是防病毒软件。。。。。。我把它设置为非活动状态,一切都很好。。。我不想指出这个软件是什么,只是想提醒一下这个问题。。。。
相关文章:
- 如何从给定字符串中删除第二次和第三次出现的$
- getopt_long_only第二次调用时返回 -1
- 读取文件在第二次调用时返回INVALID_HANDLE
- C++:std::ofstream 方法 open() 在第二次迭代时擦除打开的 ifstream 文件
- 解释为什么第二次分配会改变性能
- 当再次触发信号时,从Qt插槽执行的功能被第二次调用时会发生什么?
- 如何防止GUI挂起,同时允许第二次操作与Qt中的第一次操作一起执行
- 如何找到数组中值倒数第二次出现的索引
- arm_data在第二次运行我的程序时中止失败,然后
- Java 套接字读取在第二次读取时返回奇怪字符
- 提升 Asio SSL 无法第二次接收数据(第一次确定)
- CUDA 内核在第二次运行时运行得更快 - 为什么?
- 第二次调用 PyObject_CallObject() 失败
- 第二次运行C++时无法编译
- 第二次创建命令缓冲器时,在VKCMDDrawIndex中进行了segfault
- C++ - 第二次二叉搜索的分段错误
- 第二次调用 PyObject_CallObject() 时分段错误
- Visual C CLR设计器在项目的第二次运行和编辑设计中始终显示0x8000000A错误
- 矢量插入分段错误第二次迭代
- 用IDE编译c++代码,第二次出现错误