问题描述
这是我试图用gcc编译一个简单的hello world程序时得到的。
c:\> gcc hello.c
hello.c:9:2:warning:文件末尾没有换行符
C:\MinGW\bin\..\lib\gcc\mingw32\\ \\3.4.5\..\..\..\..\mingw32\bin\ld.exe:无法打开输出文件a.exe
:权限被拒绝
collect2:ld返回1退出状态
它是否与Windows 7管理权限有关? p>
如果输出文件正在创建,但无法打开,它位于何处?
大部分noobie问题。我一直使用Dev-C ++编译我的源代码到现在。我尝试搜索周围的错误,但所有我可以发现是文件已经打开,但没有提到这样的exe任务管理器。
编辑:位于C:\hello.c
如果我把它放在其他驱动器上,我能做到吗?
当我把文件放在D:\并尝试改变它到任何其他驱动器使用cd d:\不会更改驱动器。
是否是权限问题,您不能在管理模式下运行命令行窗口。
在C:\
将文件复制到我的文档下的文件夹或C:或其他驱动器的子文件夹。
或者,如果你真的想在C:的根目录下运行控制台:
在管理员模式下运行控制台切换到D: ,只需键入D:(只有在已经在正确的驱动器上时使用CD)
This is what I get when trying to compile a simple hello world program with gcc.
c:\>gcc hello.c
hello.c:9:2: warning: no newline at end of file
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot open output file a.exe
: Permission denied
collect2: ld returned 1 exit status
Does it have something to do with windows 7 administrative privileges?
If the output file is being created but cannot be opened, where is it located?
Sorry if this is too much of a noobie question. I have been using Dev-C++ for compiling my source code till now. I tried googling around the error but all i could find was the file is already open, but there is no mention of such exe in task manager.
Edit: Also the file is located at C:\hello.c
Will i be able to do it if i place it in other drive?
When i place the file at D:\ and try change it to any other drive using cd d:\ doesn't change the drive.
Yes it is a permissions issue, you must not be running the command line window in Admin mode.
Don't work in C:\
Copy the file to a folder under my documents, or a subfolder of C:, or another drive.
Or, run the console in Administrator mode if you really want to work in the root of C:
To switch to D: while in C:, just type D: (you use CD only when already on the correct drive)
这篇关于在Windows 7上使用GCC编译:\mingw32\bin\ld.exe:无法打开输出文件a.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!