Sunday, 2 November 2008

Installing & Using The Borland C++ Compiler


The Borland C++ Compiler is a command line based C++ compiler for Windows. I have been using DevC++ as my C++ IDE, but I decided I wanted to write the source in notepad & just use a simple command line compiler to compile it. Due to some of the difficulties I had with installing & using it, I decided to write a tutorial about installing it & using it. There is a Borland IDE, but the command line version is free.


Downloading It

Firstly, I will give the link to the download page. This is a link to the official page -
http://cc.codegear.com/Free.aspx?id=24778

The first thing you notice, is that you need to register with them to download it. So we are going to just give them a fake email address & fake infomation. Obviously, pick the correct country, so it gives you the right language.
You will have to have cookies enabled for the page. Left click the 'Create Account' button. You should now have a 'Download Now' botton on the page. Left click it.

Now you have to agree to their TOS. Their TOS says you can't make nuclear weapons with their product, so if that was the plan don't download it... =)

Click 'Agree (Let Me Download It)'.

Now your download manager will come up asking you what to do with it. Tell it to save the file onto your desktop. Now wait a few seconds whilst it downloads. Once it's downloaded, go onto the next step.


Installing It

Now, there should be a icon oon your desktop that's called 'freecommandLinetools.exe'. Run it. Now a installation wizard has came up. Press 'Next'. It will ask you where you want to put the Borland Compiler. Let it install it in the default directory. Once done, click 'Finish'. A dialog box will come up. Click 'Yes'. Now it will begin to install. Once the installation has finished, a dialog box will come up. Press 'OK'.

Using It

Unlike most programs, Borland Compiler won't place any shortcut on the start menu. So we will have to find the program ourselves. I'm assuming from now on that you installed it in the default directory. In Windows Explorer, go to C:\Borland\BCC55\Bin. We can't just run the program by clicking on it, as it just shuts down as soon as it opens up. So we have to run the program from the command line. First, open the command line by typing cmd into the run dialog box. Now you should have the command prompt on screen. Type cd
C:\Borland\BCC55\Bin into the command prompt & press enter. Now type bcc32.exe & press enter. Now the compiler have been opened. To compile a file, you would type bcc32 -path of c++ source file- -Destination of binary-. See the next section for more infomation.


Example

I have just written a C++ source file in Notepad. First, I would save the file in Notepad by pressing CTRL-S. Then I would change the 'Save As Type' drop down menu to 'All Files'. Then I would name it Filename.cpp .Now I would work out the path of where I saved it. I saved it in c:\programs\program.cpp. I want the compiled binary to end up in c:\program.exe So, then I would run The Borland Compiler and type -

bcc32
c:\programs\program.cpp -n c:\program.exe

Then it should turn the .cpp file into a .exe file. The compile has worked. You can now run the .exe file by double clicking it.

That's how to use the basic elements of The Borland Compiler

0 comments:

Post a Comment