![]() |
Tutorials > C++ > Setting Up Your Environment IntroductionThis tutorial will show you how to setup your environment to program in C / C++.
Microsoft Visual Studio.NET
Visual Studio.NET (VS.NET) should already be installed. Open up VS.NET and click on File > New Project.
Enter a project name such as Test and click OK
Click Finish. If you do not see your Test project in a Solution Explorer window, click on View > Solution Explorer
Right-click on Source Files in the Solution Explorer and select Add > New Item Dev-C++Dev-C++ should already be installed. I am using the Dev-C++ Version 5 beta. This can be downloaded from www.bloodshed.net
Click on File > New > Project
You will be presented with a file containing a number of lines of code. This code will be explained in a future tutorial. For now, click on Execute > Compile and then click Save to save your main.cpp file. You may get an error that iostream cannot be found. I have found this to be a problem with Dev-C++ on first install. To fix this you will have to setup some compiler options. This should only need to be done once and then each project you create afterwards, should work perfectly.
Click on Tools > Compiler Options.
You should now be able to compile your program perfectly and when you click on Execute > Run, you should get a command prompt that says "Press any key to continue . . .". You have successfully set up Dev-C++ to program in C++ and you now know how to start a new project. Unix / LinuxFor those of you taking the Unix route, congratulations on embarking on the journey that many people are afraid of. Do not worry though, as most of the programming works exactly the same way and you are able to accomplish so much more utilizing the power of Unix / Linux.
Open up any terminal and type g++ Type touch main.cpp which will create a 0 byte file. You can also do this using any visual editor or a console editor such as vi. Create another file in the same directory called Makefile. This is used to automate the compile process. You will see how this is achived further down. Type the following for the contents of Makefile : main : main.cpp g++ main.cpp -o main clean : rm -rf main
Now when you type make, you will compile your source file. The resulting executable
is specified by the -o. In this case it is main.
The clean section shows what will happen if you type make clean Congratulations! You now know how to create a makefile in Unix / Linux and you know how to go about compiling your source files. Please let me know of any comments you may have : Contact Me
All Rights Reserved, © Zeus Communication, Multimedia & Development 2004-2005 Read the Disclaimer |
|