I am new in Ubuntu. Now I am using ubuntu 12.04(lts). I want to run my C programming code (.c/.cpp). But I dont know how to compile and run code in ubuntu. SO i need help. Please tell me How can I run single .c code in ubuntu.
I assume there is terminal emulator widget in your geany (which is suggested by geany package). Click on it (In lower-left corner) and first navigate to folder in which is your source file:
To compile file YourSourceFile.c type:
gcc YourSourceFile.c -o ProgramName
To run the program type:
In Geany you can execute your code in two ways. In the first way you can click at Build option at the global menu there you can find options for compiling ,building and executing. Look at the image
If you are a hotkey lover then you can do with hotkeys also. Here F8 for Compiling and F5 for Running the C program.
If you don't already have the compiler installed, you'll need to install it and other development tools:
sudo apt-get install build-essential
Once that's done, the compiler command is
gcc. To compile code from the command line run:
This will, if successful, produce an executable called a.out. Run the command:
If you want a different executable name, use the
-o option with
gcc sourcefile.c -o myprogram
This will produce an executable called myprogram. Run it as you did a.out:
Once you've installed everything and have the basics down, then using geany or other programmer's editors to run your build can be don as Jai noted.