Professional Documents
Culture Documents
Compile C Code
Compile C Code
Ubuntu
edits by:Feelshift, SudoKing, Teresa, Maluniu (see all)
Article
EditDiscussView History
1. 1
Install the build-essential package by typing the following command in the
terminal: sudo apt-get install build-essential
Ads by Google
2. 2
Now create a file that has the extension .c (if you plan to write a C program) or
.cpp (for a C++ program).
3. 3
Write the code in that file.
4. 4
Now open a terminal and go to the place where you saved that file using the cd
command (e.g. cd Desktop).
5. 5
6. 6
If you have a C++ program simply replace gcc with g++ and hello.c
with hello.cpp. The options do the same things.
7. 7
If you get a permissions error, you need to make the file executable. You can
do this with chmod +x hello.cpp
8. 8
Now type in the terminal ./hello and the program will run.
Ads by Google
Virtual Terminal
Process Credit Card Transactions From Any PC. Call 888.208.1593
www.ChasePaymentech.com
System Administration
Expert System Administration Services for your Business
www.infidati.com
EditTips
Obviously, you can name the files however you want.
A great article about Programming in C in Ubuntu is in the Issue #17 - September
Code Coverage
Try dotCover for Code Coverage in .NET and Silverlight apps.
www.jetbrains.com
Computer Programming
Computer Programming Education Courses at Accredited Schools.
Technology-Schools.com
EditWarnings
If you don't use the -o option the name of the executable will be a.out (by default).