Hello, I am completely new to C++, but I want to learn how to program. I’m running Linux. Can someone help?

Posted Friday, May 22, 2009 by admin


Hello, I am running Linux on my PC. I want to learn how to program, and I have a book on writing code in the C++ language. I wrote my first program, very short safe and simple, following instructions from the book. I used the KWrite text editor in Linux Mandriva 2009. Unlike Windows, where you canm just put the file extension as “.exe” and click on it, you have to do something called “compiling” in Linux (I think :( ). Now, I saved it as .cpp, I think that was what I was supposed to do. But I can’t figure out how to run it. Any tutorials I have found claim to be for a complete beginner, but then I can’t understand them at all. I just want to run it to see if it will work. All the tutorials have me going into the command prompt ( well I think Linuxes is called Konsole) and typing stuff like “gcc” but I don’t know what any of that is. Apparently I need a compiler, but I don’t really know what that is, or how to use it, or how to install it; especially since the Linux way of installing is so much diferent from Windows’! I finally managed to install LimeWire…:P But anyway, does anyone know if I need a compiler for Linux, and where to download one for Linux, and how the heck to install it on Linux? And then how would I re-write my program in it, or would I just have to do something in Command Pr–uhhh…Konsole? :P Also, the book said to put my “include directive” (#include) as “iostream.h” But when I run this in Konsole, it says the directive does not exist on my system. Ughhh. So, I would REALLY like some help. My book gives a simple program to take the peas in a pod, the number of pea pods, and uses the program to find out the total number oif peas. Also, if anyone could find me any tutorials on how to download and install a “compiler” if I need one, and anything else that is needed, for LINUX, and how to write programs using that compiler and then how to actually run them on Linux, and what the name of my include directive should be, then I would be eternally greatful. Thanks everyone, if you need to write a more complicated answer, feel free to contact me via AIM:
ryanleonhart94
Yahoo Messenger:
squall_94
or my e-mail address:
squall_94@yahoo.com
Thanks again, everyone, in advance. I’m really looking forward to doing this and finding out if my program works (even if I did copy most of it from a book!) And as you can tell, I’m a Linux newb. :P I look forward to answers!
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Ask

1 Comment on "Hello, I am completely new to C++, but I want to learn how to program. I’m running Linux. Can someone help?"

  • Fred W said on May 25th, 2009 at 1:02 AM:

    First, the operating system is not “Linux”; Linux is the kernel. The operating system is Mandriva.

    Now, on to specifics. I am not familiar with Mandriva, but I assume that it uses KDE, and there is a “start” button. Look for a system tool like “add programs”. Select it. You are looking for “GCC”, which is the GNU Compiler suite. Install it.

    When you call up a terminal (Konsole), type

    g++ fill_in_your_program.cpp

    This will compile your program. If there are no errors, execute it by typing

    ./a.out

    This will run your program. Note that the “#include” directive only makes sense when typed INSIDE your source file. It tells the compiler (and, yes Virginia, Windows uses compilers too) about the extras your program needs.

    Good Luck!

Leave a Comment