Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CST8152 – Compilers

Creating a Console Project with Borland C++ Compilers

A. Creating a Console (DOS) Project with Borland C++ 5.02


Borland C++ compilers are among the best in the world, and provide facilities that are
perfectly suited to a creation and an exploration of complex programming projects. They
are relatively small, reliable, and most important ANSI C compliant.

To create a DOS Project with Borland C++ 5.02 IDE follow the steps (rather clicks ☺)
outlined below:

AS1. Launch the Borland C++ 5.02 compiler (IDE)


1. Launch Borland C++ 5.02 IDE. Once the Integrated Development Environment
(IDE) appears, close all document windows if you have any open.

AS2. Create a Project


2. Select File, New, Project from the main menu bar. The Target Expert wizard will
appear.
3. Specify the Project Path and Name. Use the same directory (folder) where you plan
to save your source files. The project is saved in a file with the extension .ide. For
example: n:\compiler\lab0\cdtypes.ide or better n:\compiler\lab0\cdtypes.ide
Do not use a floppy diskette as your working directory, as unexpected results may
occur.
4. Specify the Target Name: For example cdtypes. It can be different from the project
name. This will be the name of your executable program.
5. Specify the Target Type: Application[.exe]
6. Specify the Platform: DOS (Standard) (also called a command-line program or
console program).
Note: DOS (Standard) creates a 16-bit project (application). To create a 32-bit
project select Win32.
7. Specify the Target Model: Large.
8. First uncheck Class Library checkbox, then click the Floating Point radio button.
Make sure that No Exceptions, BGI, and Alternate Startup are unchecked.
9. Click on the Advanced button and select No Source Node. Click the OK button.
10. Click OK in the Target Expert and you should see the Project document window.
If you do not see it, or you close it unwittingly, select View, Project from the main
menu bar. There should be only one line in the project window containing the name
of your project target cdtypes.exe [.exe ]. This is the root node of the project tree.
If you have more lines, delete them following the instructions below.

AS3. Specify the Project Options


11. Click with the mouse on the project target name cdtypes.exe [.exe]. Once
highlighted, click with the right button. Select Edit Local Options. The Project
Options window will appear. You can open the same window using the Options,
Project from the main menu bar.
CST8152 – Compilers Page 1 of 4
12. Select Directories. Specify your Source, Intermediate, and Final directories. If you
choose to leave them empty, the project directory will be used as a repository for
your files. You can specify different directories for your source files (.c and .h),
intermediate files (Borland temporary files), and final files (.obj and .exe).
13. Select Compiler. Compiler will have either a – or a + symbol to the left. If you have
the + symbol, click it to expand it and to make the Compiler sub-options visible.
14. Select Code Generation. Check Allocate enums as ints.
Select Source. Check ANSI. This is a very important option. It will force the
compiler to comply with the ANSI C standard. Your project must be ANSI C
complaint.
15. Select Debugging. Check Test Stack Overflow.
16. Select Precompiled headers. Select Do not generate or use radio button. Using
the Precompiled headers will make the compilation faster but will consume several
megabytes of disk space (even for small projects) and will prevent the symbolic
debugging of the header files. You should ensure that this productivity feature is
turned off.
17. Select 16-bit Compiler. Select Processor. Check i486.
18. Select Messages. Check all the boxes in the Portability, Potential Errors, and
ANSI Violations options.
19. Now your Project Options specification is complete. Click the OK button and move
to the next step.
20. Save the project. Creating and specifying your project options does not save your
project file (cdtypes.ide) automatically. To save the project you must close the
project using Project, Close project option from the main menu bar. This action
will close the project window and will save the project file. To continue working with
the project, use Project, Open project and select the project name (cdtypes.ide).
Click the Open button.

AS4. Add Source Files to the Project


21. Click with the mouse on the project target name cdtypes.exe [.exe].Once
highlighted, click with the right button. Select Add node. Add to Project List
window will appear. Select your .c file (for example cdtypes.c). If the file does not
exist yet, type the file name in the File name text box. Click the Open button.
Repeat the operation if you have more source files (.c or .h). If you made a mistake,
use Delete node option after right clicking on the wrong file name. When you add
more .c or .h files always click on the target file name [.exe] (the root of the project
tree). All .c files must be sub-nodes of the project target [.exe].
22. Save the project file (see step AS3 item 20).

AS5. Write or Edit the Source Files


23. Now you can open your .c and .h files if they already exist. If they do not exist yet
but they are specified in your project (see above) you should open a text edit
window. You can do this using the File menu option or using the mouse in the
project window. Highlight the file name, click the right button and use the View ,
Text Edit option. You can write new files and add them to the project at any time.

AS6. Compile and Build your Application

CST8152 – Compilers Page 2 of 4


24. To compile and/or link your program, you can use the Project main menu, the tool
bar (use the “bubble” help boxes to find out the functions assigned to the buttons),
or you can click with the right button on the target [.exe] file in the project window
and select Build node. You can compile your .c files one by one right-clicking on
them and using the C Compile option then link the object files using the Link option
clicking on the project target. For the same purpose you can use the three icons on
the main menu bar (the icons with 100101). The first is Compile, the second is
Make, and the third is Build.

AS7. Run the Application (Program)


25. To run the program, you should open a Command prompt or DOS window. Do not
use the lightening bolt button.
There are many ways to open a Command Prompt window: you can choose Start,
Programs, Accessories, Command Prompt, or alternatively, Start, Run, type cmd
or command, and click OK; in our labs you can also click on the Windows
Command Processor icon located on the right of the Start button on the Task
bar. Once you have the command prompt window opened, use the cd command to
navigate to your project directory (for example, n:\compiler\lab0\), type the name of
your executable (for example, cdtypes) and press Enter. If your application
requires command line arguments (and the compiler project will require some) you
must type them separated with a space after the program name. Do not forget to
make the directory containing your executable (target file cdtypes.exe) current.

Borland C++ 5.5 Command Line Tools


This compiler is installed in our labs. It is a free compiler you can download from the
Embarcadero web site:

http://edn.embarcadero.com/article/21205
or
http://www.embarcadero.com/products/cbuilder/free-compiler

It is a command line compiler. There is no IDE and it runs only in a DOS window. It is
very easy to use and it is fast. To enforce ANSI C you must use the –A option. To set
the environment for Borland 5.5 you must go to Start, Programs, Programing &
Development, Borland C++ Compiler, Borland C++ Compiler. It will set the environment
and will open a DOS window for you. Now you can compile, link and run your program.
Example: N:\>bcc32 –A cdtypes.c
This will compile, link and generate cdtypes.exe file. When you want to compile a
project containing more than one file, you do so through simply typing all .c ( and/or
.obj) file names separated with a space. No need to create a project.
The compiler supports all the options you can find in the Project Options window.
To find how to set them, open the Project Options window using Borland 5.02 IDE,
select the option you interested in and click the Help button. It will explain the option
and will give you the command line settings.

Possible problems

CST8152 – Compilers Page 3 of 4


The compiler generates only 32-bit applications.

A. Creating a DOS Project with Borland C++ 4.52

To create a DOS Project with Borland C++ 4.52 follow the steps outlined bellow:

1. Run Borland C++ 4.52 and close all documents windows if you have some open.
14. Select Project, New project from the main menu bar.
15. Specify the Project Path and Name. Use the same directory (folder) where you
save your source files.
16. Specify the Target Name. For example lab0.
17. Specify the Target Type: Application[.exe]
18. Specify the Platform: DOS (Standard) (also called a command-line program or
console program).
19. Specify the Target Model: Large.
20. Specify the Standard Libraries: First uncheck everything then check Runtime
and Floating Point.
21. Click on the Advanced button and select No Source Node. Click OK.
22. Click OK and you should see the Project document window.
23. Move the mouse cursor there and click on target name [.exe]. Click with the right
button. Select Add Node. Add your lab0.c file. If the file does not exist, type the
name in the File Name text box. Repeat the operation if you have more xxx.c files.
24. Click with the right button. Select Edit Local Options. Select Directories. Specify
your Source, Intermediate, and Final directories. If you leave them empty, the
current one will be used.
25. Select Compiler>Source. Select ANSI. Select Compiler>Debugging. Check Test
Stack Overflow. Select Compiler>Precompiled headers. Check Do not generate or
use.
26. Select 16-bit Compiler>Processor. Check i486.
27. Click on OK button and your Project is ready.
28. Now you can open your .c and .h files if they already exist. If they do not exist yet
but they are specified in your project (see step 11) you should open a text edit
window. You can do this using the File menu option or using the mouse in the
project window. Highlight the file name, click the right button and use the View,Text
Edit option. You can write new files and add them to the project at any time.
29. To compile and/or link your program, you can use the tool bar or you can click with
the right button in the project window and select Make node, Build node, or Link.
30. To run the program, you must open a DOS window and type the target program
name and the command line arguments at the command line. Do not forget to make
the directory containing your xxx.exe file current.

S^R, 2013

CST8152 – Compilers Page 4 of 4

You might also like