Programming on Linux

Submitted on: 1/3/2015 5:39:00 AM
By: Lee Trager (from psc cd)  
Level: Advanced
User Rating: By 6 Users
Compatibility: C, C++ (general), UNIX C++
Views: 2935
     This will show you how to code in Linux using g++.

				Not many people are using Linux right now, or even programming in it. But its pretty easy. You hear alot about gcc, but thats just for C if you want use C++ in your programs you need to use g++. Some versions of Linux don't have all the header and libary files, like Mandrake. But these are the advanced files like OpenGL and OpenAL. For these files search for them on sites like,, and/or the site of the people who make your version of Linux.

First what you have to do it open a text or code editor(what ever comes with your version of linux. Something like vi or Advanced Editor. If your using an editor make sure it is set to C++. Now code as your normaly do. You will find some diffrences like when a program closes in win(in console) is says "Press any key to countinue..." in linux this dose not happen, so... You have to use a dummy so a program like hello world wont just pop up then close.

A simpal hello world program is something like this.

#include < iostream.h >
int main(void)
char dummy[2];
cout << "hi\n";
cin >> dummy;
return (0);

Now that you have coded something you have to save it. Make sure it is saved as a cpp file it is important. Save it some were that you know like your user dir. Go into Terminal or Konsole(what ever your version calls it) and type these commands.
cd the directory of the file

If you want to see the files in that dir type ls

g++ hello.cpp filename.cpp -o hello were you want the exe to save

That will compile your code if there are any errors or warnings g++ will tell you about them. Now goto that dir that it compiled in and click on it. If it dose not open up right click on it and check "Run in terminal".

Please Write comments

Other 5 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Advanced category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.