使用GCC编译C代码 [英] Using GCC to compile C code
问题描述
我在 Windows 8笔记本电脑上安装了MinGW,并尝试使用
I installed MinGW on my Windows 8 laptop and tried to compile a C code file with
gcc test.c -o test.exe
编译器未给出警告或错误,但没有给出警告或错误创建test.exe
the compiler gave no warnings or errors but it did not create test.exe
我如何让编译器创建文件
how do i get the compiler to create the file
test.c
我的终端会话
My terminal session
一个有趣的发现:
当我故意在代码中引入错误并尝试编译时,编译器会显示错误
When I deliberately introduce an error in the code and try to compile the compiler shows the error
有错误
的代码
编译器输出
Code with error Compiler output
当我尝试使用Comm编译相同的代码时和提示
When I try compiling the same code using Command Prompt
这是显示的内容
This is what it shows
但是该文件确实存在于MinGW\bin目录
But the file does exist in the MinGW\bin directory
我移动了
test.c
文件到
C:\
并在$ p
$ b
and started the command prompt in the
C:\MinGW\bin
目录
这是它输出的内容
and here is what it outputs
部分解决了问题:
我在Windows 8中禁用了混合启动,并重新启动了计算机。
I disabled hybrid boot in windows 8 and restarted the computer. The compiler now works in Command Prompt but not in PowerShell.
推荐答案
尝试正常编译代码为
gcc test.c
如果获得默认输出文件 a.exe
,然后进行
If you get default output file a.exe
,then go for
gcc test.c -o test.exe
这篇关于使用GCC编译C代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!