0

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

2
  • 3
    Try ./a.out on the commandline. Commented Aug 31, 2011 at 4:35
  • ^ Yes. Also look into Makefiles for making several different executables or when you have several interlinking dependencies. youtube.com/watch?v=o6x0EHAzCJc Commented Aug 31, 2011 at 4:39

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Run using ./myprogram, not myprogram (from the directory you saved it in - I know you know that, Alex, just as he's confused)
0

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

1 Comment

Not likely; gcc gives a.out execute permission. If you double-click an `a.out’ file (probably from Nautilus), it should execute it, but not in a terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.