This is what I get when trying to compile a simple hello world program with gcc.
这是我在尝试编译一个与gcc的简单hello world程序时得到的结果。
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?
它是否与windows 7的管理权限有关?
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.
不好意思,如果这个问题太多了。到目前为止,我一直在使用devc ++编译源代码。我试着用google搜索这个错误,但是我能找到的只是文件已经打开了,但是在任务管理器中没有提到这样的exe。
Edit: Also the file is located at C:\hello.c
编辑:文件也位于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.
当我把文件放在D:\并试着用cd D改变它到任何其他驱动器:\不会改变驱动器。
3 个解决方案
#1
6
Yes it is a permissions issue, you must not be running the command line window in Admin mode.
是的,它是一个权限问题,您不能在管理模式下运行命令行窗口。
Don't work in C:\
不工作在C:\
Copy the file to a folder under my documents, or a subfolder of C:, or another drive.
将文件复制到我的文档下的文件夹,或C的子文件夹,或另一个驱动器。
Or, run the console in Administrator mode if you really want to work in the root of C:
或者,如果您真的想在C的根中工作,则可以以管理员模式运行控制台:
To switch to D: while in C:, just type D: (you use CD only when already on the correct drive)
切换到D:在C:,只键入D:(只有在正确的驱动器上才使用CD)
#2
0
The most common case is that your program may still be running in the background, possibly hanged on an endless loop. You can try searching for the process in the process list (press Alt+Ctrl+Del) and killing it.
最常见的情况是,您的程序可能仍然在后台运行,可能挂在一个无限循环上。您可以尝试在进程列表中搜索这个过程(按Alt+Ctrl+Del)并杀死它。
#3
-2
The g++.exe-command in the build-log in the CodeBlocks-IDE shows the command with an additional path: C:\MinGW\lib
, which is wrong.
g + +。在codeblock- ide的构建日志中,exe-command显示了一条附加路径的命令:C:\MinGW\lib,这是错误的。
-
If you copy the command to a cmd-window (in the directory of your Project) without the
C:\MinGW\lib
the compiler works. When you copy the command as shown inCodeBlocks-Buil-log
it fails, with the same message in the cmd-window.如果您将该命令复制到一个cmd窗口(在您的项目的目录中),而没有C:\MinGW\lib编译器工作。当您复制codeblocks - build -log中的命令时,它将失败,并在cmd窗口中使用相同的消息。
-
Have a look at the
Settings > Compiler > Search Directories > Linker
. You've got to delete theC:\MinGW\lib
there, but the bug is, that it is not deleted if you do it once. You've got to repeat it and then it works.看一下设置>编译器>搜索目录>链接器。您必须删除C:\MinGW\lib,但是错误是,如果您执行一次,它不会被删除。你得重复一遍,然后就可以了。
#1
6
Yes it is a permissions issue, you must not be running the command line window in Admin mode.
是的,它是一个权限问题,您不能在管理模式下运行命令行窗口。
Don't work in C:\
不工作在C:\
Copy the file to a folder under my documents, or a subfolder of C:, or another drive.
将文件复制到我的文档下的文件夹,或C的子文件夹,或另一个驱动器。
Or, run the console in Administrator mode if you really want to work in the root of C:
或者,如果您真的想在C的根中工作,则可以以管理员模式运行控制台:
To switch to D: while in C:, just type D: (you use CD only when already on the correct drive)
切换到D:在C:,只键入D:(只有在正确的驱动器上才使用CD)
#2
0
The most common case is that your program may still be running in the background, possibly hanged on an endless loop. You can try searching for the process in the process list (press Alt+Ctrl+Del) and killing it.
最常见的情况是,您的程序可能仍然在后台运行,可能挂在一个无限循环上。您可以尝试在进程列表中搜索这个过程(按Alt+Ctrl+Del)并杀死它。
#3
-2
The g++.exe-command in the build-log in the CodeBlocks-IDE shows the command with an additional path: C:\MinGW\lib
, which is wrong.
g + +。在codeblock- ide的构建日志中,exe-command显示了一条附加路径的命令:C:\MinGW\lib,这是错误的。
-
If you copy the command to a cmd-window (in the directory of your Project) without the
C:\MinGW\lib
the compiler works. When you copy the command as shown inCodeBlocks-Buil-log
it fails, with the same message in the cmd-window.如果您将该命令复制到一个cmd窗口(在您的项目的目录中),而没有C:\MinGW\lib编译器工作。当您复制codeblocks - build -log中的命令时,它将失败,并在cmd窗口中使用相同的消息。
-
Have a look at the
Settings > Compiler > Search Directories > Linker
. You've got to delete theC:\MinGW\lib
there, but the bug is, that it is not deleted if you do it once. You've got to repeat it and then it works.看一下设置>编译器>搜索目录>链接器。您必须删除C:\MinGW\lib,但是错误是,如果您执行一次,它不会被删除。你得重复一遍,然后就可以了。