Getting Started for Programming

In this tutorial you will learn how and where you can get started programming right away! You can choose whichever method you prefer. I’ll be teaching you how to program in a later tutorial!


1. IDE in Windows
2. Installing Linux to program in that environment
3. IDE in Linux or Mac OSX
4. How to compile your code in an IDE, or a terminal in Linux.

Integrated Development Environment in Windows

An IDE provides you with the tools necessary to start programming right away whether it be on Windows or Linux! I’ll teach you how to get started with CodeBlocks for Windows. You may choose to use a different IDE of your choice.


CodeBlocks
1. Download CodeBlocks with the minGW compiler and install on your PC.


2. Once installed, Create a New Project and click on Console Application





3. Click Next


4. Choose C++ and Next


5. Fill in the next page similar to what I have below. I recommend to have all your projects organized so place them in a separate folder from the rest of your files.





6. Click Next until you finish.


7. On the left click on Sources under Hello World, and double-click on main.cpp


8. You are done! You can start programming right away!


What should you know? You simply need to hit F9 to Build and Run your program! Your program should run in a console that will pop up.

Getting started under Linux

If you want a Linux environment you can go ahead and grab Ubuntu and install it with the following Ubuntu Installation Guide. I’ll post a guide later if people are having trouble. You can also check my Linux Distribution Ubuntu article to get more familiar with this OS.






1. Open up your terminal in Linux.


2. Go to an appropriate folder to start your programming projects.


3. Open a text editor. I usually try emacs, or vim. For starters, we’ll start with emacs.


4. In your terminal type in

emacs hello_world.cpp



5. Start writing! To compile, simply type in

g++ hello_world.cpp



6. To run your compiled code simply type in

a.out



Or you could possibly need to type in

./a.out

*Note if you don’t have emacs or g++ installed, you should receive a message such as emacs not installed and will give you a command to install it. Yes, its that easy! It would be something similar to


sudo apt-get install emacs


**Commands to get around in your terminal are

cd FOLDERNAME                                  //Change to folder
cd..                                                  //Go back one folder
cd                                                    //Go back to home directory
mkdir FOLDERNAME                              //Create folder
ls                                                     //Display contents of folder




I’ll write a more detailed tutorial later on for this section.

Installing an IDE in a Linux or Mac OS X

You can simply download Codeblocks or Eclipse for either Linux or Mac OS X as well as Windows. Follow the appropriate installation instructions to get started. Once in the IDE, choose a project, and you usually compile your code with F9. Look for Build and Run.



I’ll write a more detailed tutorial later on for this section as well.

How to compile your code in an IDE, or a terminal in Linux.

In an IDE simply look for a Build and Run option. Usually F9 does the trick. This will compile and run your code! If errors occur, you’ll be displayed with error messages based on your code.



To compile a program in Linux in your terminal, make sure the file is in the folder you are currently in.

g++ program.cpp
a.out
OR
./a.out


If you are having problems feel free to start asking questions!

Tags: ,