README.md

December 4, 2022 ยท View on GitHub

Programming on Linux

Description

This will show you how to code in Linux using g++.

More Info

Submitted On
ByLee Trager
LevelAdvanced
User Rating3.8 (23 globes from 6 users)
CompatibilityC, C++ (general), UNIX C++
CategoryDebugging and Error Handling
WorldC / C++
Archive File

Source Code

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 www.linux.com, www.OpenGL.org, 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);
} YOU SHOULD HAVE A SPACE AT THE END OR IT GIVES YOU A WARNING


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