Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a .c file and some random program that popped into my head. Now I'm trying to run it from the terminal. I'm new to ubuntu so it's hard for me to input the commands needed for it's compiling etc. I've saved my file at desktop. I will be grateful if anyone helped me with the full syntax which includes compiling and installing(stuff like I don't know qemu or gcc which I saw on this site) Thank you.

share|improve this question

closed as off-topic by muru, Pilot6, Eric Carvalho, Fabby, David Foerster Mar 7 at 10:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – muru, Pilot6, Fabby
If this question can be reworded to fit the rules in the help center, please edit the question.

If the program is simple just do this:

cd Desktop
gcc program.c -o program
./program

First command puts you to the Desktop where you put the program. The second line compiles the program if it does not use some strange libraries. The third line executes it. Change word program with the name you have given to the file.

share|improve this answer

The gcc compiler comes with all Linux distro's. The syntax is

gcc -o desiredName program.c

And to run the program use

./desiredName

Of Course there are more options you should add. '-Wall' will print out all the warnings and errors when your try to compile it. Be sure to set up a standard as well. The C language used in the kernel is not standards compliant, it is a superset which includes GCC extension, which is why i would recommend gnu99 -std=gnu99. However, the C standard is C99 -std=c99 I also, personally set up an alias, so I don’t have to type this stuff out all the time. I recommend that you do the same.

alias cc="gcc -Wall -std=gnu99 -o "

Now all you have to do is type

cc desiredName program.c
share|improve this answer
2  
Why -std=gnu99? – muru Mar 5 at 16:16
    
For each language compiled by GCC, there is a standard, GCC attempts to follows many versions of that standard, possibly with some exceptions, and possibly with some extensions. gnu99 is the recommended standard. – Andrew Kralovec Mar 6 at 15:49
1  
Recommended by whom? Why not C11? Why recommend using non-standard extensions at all? – muru Mar 6 at 15:51
    
the C language used in the kernel is not standards compliant, it is a superset which includes GCC extension. Hence gnu99. – Andrew Kralovec Mar 6 at 15:52
    
Who said OP is doing kernel programming? They're just starting out. – muru Mar 6 at 15:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.