Dev C++ 编译错误,权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10463958/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 14:05:34  来源:igfitidea点击:

Dev C++ compilation error, permission denied

c++compilationdev-c++

提问by youmir ali

I want to compile a code program using dev c++ compiler but my compiler didn't compile my code.The program consist of two files one is header and other is implementation .cpp file. The code i want to compile is correct and working,but it didn't compiling on my pc(windows 7) Please help

我想使用 dev c++ 编译器编译一个代码程序,但我的编译器没有编译我的代码。该程序由两个文件组成,一个是头文件,另一个是实现 .cpp 文件。我想编译的代码是正确的并且可以工作,但它没有在我的电脑上编译(windows 7)请帮忙

The error which i am getting is

我得到的错误是

  Permission denied 
  ld returned 1 exit status 
  C:\Makefile.win [Build Error]  [Project1.exe] Error 1 

here is my compile log

这是我的编译日志

Compiler: Default compiler
Building Makefile: "C:\Makefile.win"
Executing  make...
make.exe -f "C:\Makefile.win" all
g++.exe -c testProgDoublyLinkedList.cpp -o testProgDoublyLinkedList.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"   

g++.exe testProgDoublyLinkedList.o  -o "Project1.exe" -L"C:/Dev-Cpp/lib" -mwindows  

C:\Dev-Cpp\Bin\..\lib\gcc\mingw32.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot open output file Project1.exe: Permission denied
collect2: ld returned 1 exit status

make.exe: *** [Project1.exe] Error 1

Execution terminated

回答by John

Try running task manager to determine if your program is still running.

尝试运行任务管理器以确定您的程序是否仍在运行。

If it is terminate it because that's why your compiler is giving you an error.

如果它被终止,因为这就是你的编译器给你一个错误的原因。

回答by Jon

Windows 7 does not let you write directly to the root of c:\(among other locations) unless from within a process running with administrator privileges.

Windows 7 不允许您直接写入c:\(以及其他位置)的根目录,除非在以管理员权限运行的进程中。

The simplest workaround for you is to move your project from c:\to another directory -- for example, c:\projectswill work.

对您来说最简单的解决方法是将您的项目从c:\另一个目录移动到另一个目录——例如,c:\projects将工作。

回答by Ember Freak

I tried all the proposed answers in my windows 7
1. run as administrator
2. Killed the process if it is running already
3. Gave full control permission to the project folder
4. Moved to different project folder.
Nothing solved my problem. finally i tried after disabling avast anti virus..it worked.

我在 Windows 7 中尝试了所有建议的答案
1. 以管理员身份运行
2. 如果进程已经在运行,则终止该进程
3. 授予对项目文件夹的完全控制权限
4. 移至不同的项目文件夹。
没有什么能解决我的问题。最后我在禁用 avast 防病毒后尝试过..它起作用了。

回答by Mamuka Arabuli

I removed generated exe file from projects folder and error went . I am removing after every rebuld-rerun . wait 1-2 minutes if it is not removing . one time try to remove , it will refuse . leave it and it will disappear itself . meanwhile you can enjoy changes in code . tried everything , only this worked

我从项目文件夹中删除了生成的 exe 文件,然后出错了。每次 rebuld-rerun 后我都会删除。如果没有移除,请等待 1-2 分钟。一次尝试删除,它会拒绝。离开它,它会自己消失。同时你可以享受代码的变化。尝试了一切,只有这个有效

回答by ThatGuy

C:\Dev-Cpp\Bin..\lib\gcc\mingw32\3.4.2........\mingw32\bin\ld.exe: cannot open output file Project1.exe: Permission denied collect2: ld returned 1 exit status

C:\Dev-Cpp\Bin..\lib\gcc\mingw32\3.4.2........\mingw32\bin\ld.exe:无法打开输出文件 Project1.exe:权限被拒绝 collect2:ld返回 1 个退出状态

This line here is the computer saying it does not have permission to work with the specified directory. Either save your work in a new folder which the program has permission to work with or run your program as an administrator.

这里的这一行是计算机说它无权使用指定的目录。将您的工作保存在程序有权使用的新文件夹中,或者以管理员身份运行您的程序。

Kind of pointless responding to an old issue but if anyone else has this problem hopefully this will save them some time.

对一个老问题的回应有点毫无意义,但如果其他人有这个问题,希望这会为他们节省一些时间。

回答by Alistair

Windows 7

Windows 7的

If you click save all files button then close and delete the makefile and others except the .cpp, .dev, .c then reopen using either .dev or .cpp or .c and then run it works.

如果您单击保存所有文件按钮,然后关闭并删除 makefile 和除 .cpp、.dev、.c 之外的其他文件,然后使用 .dev 或 .cpp 或 .c 重新打开,然后运行它。

回答by Help

I was able to fix the same problem by creating a new folder and saving the project into that new folder. Then I also saved the source file within that same folder and everything finally executed correctly. It seemed to be a directory issue with finding the files when it was trying to execute.

通过创建一个新文件夹并将项目保存到该新文件夹中,我能够解决同样的问题。然后我还将源文件保存在同一个文件夹中,一切最终都正确执行。在尝试执行时查找文件似乎是目录问题。