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.
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.
The gcc compiler comes with all Linux distro's. The syntax is
gcc -o desiredName program.c
And to run the program use
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