【问题标题】:Compile c++ code with IDE, error at the second time用IDE编译c++代码,第二次报错
【发布时间】:2015-12-09 07:08:47
【问题描述】:

我是 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

它将继续运行,直到我关闭命令行窗口。如果我打开一个新的命令行窗口并再次编译该文件。没有问题。

更新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

它一直在这里运行。

【问题讨论】:

  • 但是当我做一些小修改时 -- 请告诉我们这个“小修改”。不要只是描述它。
  • 例如我编辑这一行:cout
  • 古怪而奇特。使用调试器遍历是否会提示它挂在哪里?

标签: c++ windows-8 ide g++ mingw


【解决方案1】:

谢谢大家,我为此苦苦挣扎了一整天。问题是杀毒软件……我把它设置为非活动状态,一切都很好…… 我不想指出这个软件是什么,只是想针对这个问题给个提示......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-25
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    相关资源
    最近更新 更多