» The Borland C++ free Compiler #1 by revolution |
|
(Login to remove green text ads)
This is a num i got from a friend, Samc who had homenuke.com. He picked it up from a site that from what i can tell is now no longer there.
Required Tools:
Borland C++ command line tools
NotePad (Text Editor)
Required Platform:
Windows 9x
Windows XP
Windows 2000
Tested Platforms:
Windows 2000
Windows XP
Let us begin with using the Borland C++ compiler. I have choosen this compiler first because it is powerful and it is free. The only thing missing from the release version you download is MFC (Microsoft Foundation Class). Maybe as we progress we will create our own classes and maybe call them TCC (Total Coder Classes) that will take over some of the functionality of MFC. This is not to mean that we will not cover topics such as MFC, but since this site's main target audience is the novice and part time developer I feel that Microsoft Visual C++ price range puts it out of the range of most of the people within our target audience. It is not that I do not recommend it, if you are going to become serious in Windows development there is nothing more that I would recommend.
In order to obtain the Borland compiler you must register and give some information about yourself. I feel that this is a small price to pay for a free compiler. Almost everything you need to start writing programs are currently available in the download and it is approximately 8Megs in size. The only thing missing in the download, and the reason that I have include NotePad as a required tool, is a text editor. If anyone has any suggestions on free or low cost code editors please let me know, so we can do a review on them as well as select one as our IDE of choice for the Borland enviornment.
Installation is pretty much straightforward. Double click on the downloaded file and keep the default installation directory which is C:BorlandBcc5. In order to simplify compiling and linking I have set the enviornment variable PATH through AUTOEXEC.BAT. If you have this file located on your computer usually on the root of the C:\drive. Open it with Notepad or right click on it and select Edit. If you do not see a line that says SET PATH add it and it should look like this SET PATH=C:\BorlandBcc5Bin click Save and exit the file. If you do not have Autoexec.bat and you are running Windows 2000 or Windows XP right click on my computer, then left click on Properties. Under Properties click on Enviornment Variable . Once there click on Path, and then Edit then goto "Variable Value" goto the end of that statement if it does not have a semicolon add it and then add the above line "c:BorlandBcc55Bin". Once you have properly set the environemnt variable you can then run the compiler from within any folder by typing in Bcc32.exe. First reboot your system and let us try running it now. After rebooting open up a command window, by click on start going to Accessories and left clicking on the icon that says "Command Prompt". When the command prompt window is displayed type in cd {return} this should bring you to the c: prompt. Once there type in bcc32 you should see something along these lines:
Code:
* Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
* Syntax is: BCC32 [ options ] file[s]
* = default;
* -x- = turn switch
* -3 * 80386 Instructions
* -4 80486 Instructions
* -5 Pentium Instructions
* -6 Pentium Pro Instructions
* -Ax Disable extensions
* -B Compile via assembly
* -C Allow nested comments
* -Dxxx Define macro
* -Exxx Alternate Assembler name
* -Hxxx Use pre-compiled headers
* -Ixxx Include files directory
* -K Default char is unsigned
* -Lxxx Libraries directory
* -M Generate link map
* -N Check stack overflow
* -Ox Optimizations
* -P Force C++ compile
* -R Produce browser info
* -RT * Generate RTTI
* -S Produce assembly output
* -Txxx Set assembler option
* -Uxxx Undefine macro
* -Vx Virtual table control
* -X Suppress autodep. output
* -aN Align on N bytes
* -b Treat enums as integers
* -c Compile only
* -d Merge duplicate strings
* -exxx Executable file name
* -fxx Floating point options
* -gN Stop after N warnings
* -iN Max. identifier length
* -jN Stop after N errors
* -k Standard stack frame
* -lx Set linker option
* -nxxx Output file directory
* -oxxx Object file name
* -p Pascal calls
* -tWxxx Create Windows app
* -u Underscores on externs
* -v Source level debugging
* -wxxx Warning control
* -xxxx Exception handling
* -y Produce line number info
* -zxxx Set segment names
Do not be scared or confused with the switches presented above for most of the work we are going to do you do not need most of the command line switches. But take a look of these switches, in the near future you should be able to look at these command line switches and understand what you are seeing but for now the only switches you should look at are the -I and -L switch. When you compile your program this switch tells the compiler where to find the "Include" and "Library" files. With the Borlad compiler you do not have to run a seperate Linker after compiling your source code in order to link your object files. The Borland compiler does this for you automatically, and creates your EXE file. For now we will look at compiling into an EXE file as opposed to a DLL, LIB, etc...
Since we now have that out of the way let us look at compiling and running our first program. Create a new directory on the root of your C: drive and call it "Prog1" by typing this at the C: prompt, and make sure your C: prompt in the command window only has this showing "C:\>:", mkdir Prog1. This will create a directory called Prog1 on the root of your C: drive. Now open up Notepad and type in this program below:
Code:
#include <iostream.h>
int main()
{
cout<<"Hello World! ";
return 0;
}
Now let us examine the lines above. The first line tells the C compiler to include the header file "iostream.h", header files define commands and keywords that are outside the native keywords within C++. C++ has certain keywords that are native to it's language that do not need any extra header files. The header file that we told it to include is "iostream.h" this tells C++ to include the keywords from this file which in our case is the cout object. This is a stream object that tells the compiler that we want to output text to screen. Some of you may have ran across the printf function in several "Hello World" examples but I wish to focus on C++ so we are going to use the C++ equivalent. Let us look at C vs. C++ not from a ranting or religous point of view, but from the point of view of these tutorials and examples. I do not mind the "C" language per se, but I am indifferent towards C++ and all the features that are available. "C" is still a strong and viable language but as an aspiring developer I feel you are going to want to use a strong and easily maintainable language. One that gives you greater manageability. Pretty soon you'll have code that goes in to the thousands of lines, if not, hundred of thousand of lines, and this is where C++ object oriented features will help you a great deal in maintaining this code. If you want to learn "C" all for it, like I said, the best programmers are the ones' who know how to use many different tools, like a carpenter who can use a saw and hammer instead of just a hammer.
Now that I got my point of view out of the way let us continue with the tutorial. Once you have this file created go ahead and save it with a .cpp ending. This tells the compiler that this is a C++ file and should compile it accordingly. Once you have saved the file and have verified that it is in the directory "Prog1".
|
|