megaed81
megaed81

Reputation: 3

How to create an executable in Ubuntu of a c program

I would like to create an executable of my two mycode.c and my main.c, how can I create an executable? i did

gcc mycode.c main.c

and it generates a a.out, but when i click it it would not run.. (i am new to this so please bear with me)

Thank you

Upvotes: 0

Views: 3036

Answers (2)

Alex
Alex

Reputation: 15333

Try this

gcc mycode.c main.c -o myprogram

Then run ./myprogram

If you double click it you probably won't see anything, you should instead try running it from the command line, where you compiled it from in the first place.

Upvotes: 2

Neilvert Noval
Neilvert Noval

Reputation: 1695

Your a.out might not be executable yet.
do:
$> chmod 755 a.out
or
$> chmod a+x a.out
then try running it:
$> ./a.out

Upvotes: 0

Related Questions