Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GCC to compile C code

I installed MinGW on my Windows 8 laptop and tried to compile a C code file with

gcc test.c -o 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

test.c

My terminal session this is what i tried on terminal

An interesting observation:

When I deliberately introduce an error in the code and try to compile the compiler shows the error

Code with error enter image description here Compiler output enter image description here

When I try compiling the same code using Command Prompt

This is what it shows enter image description here

But the file does exist in the MinGW\bin directory enter image description here

I moved the

test.c

file to

C:\

and started the command prompt in the

C:\MinGW\bin

directory

and here is what it outputs enter image description here

Problem partially solved:

I disabled hybrid boot in windows 8 and restarted the computer. The compiler now works in Command Prompt but not in PowerShell.

like image 314
lakshayg Avatar asked Jul 18 '14 07:07

lakshayg


1 Answers

Try to compile your code normally as

gcc test.c

If you get default output file a.exe,then go for

gcc test.c -o test.exe

like image 82
Sathish Avatar answered Oct 21 '22 04:10

Sathish