CIS 22 - Data Structures: How to create a project in Windows-hosted Borland C++


 
1. Creating a New Project.
2. Running Your Program.
3. Opening an Existing Project.


1. Creating a New Project.
    All program development in Borland C++ is based on projects. A Project is a list of instructions to Borland C++ that specifies how the program will be created. These instructions are stored in a file with the .IDE extension. Using a project for a simple one-file program is optional in Turbo C++ (and older versions of Borland C++) but in the Windows-hosted Borland C++ it is essential. One reason  for using project feature is to tell Borland C++ what target you want for your program: will it be a DOS program or a Windows program?

    To start, select New Project from the Project menu. This brings up a dialog called New Project. There are quite a few decisions to be made in this dialog.

1. Naming the Project:
    Type the path and filename of the program you want to create into the field called Project Path and Name. The name you see will be given to your program's .EXE file. Suppose, we are going to create a program called main. Its executable file will be main.exe. Assume it will be placed in a directory called c:\temp\win3\bcpp40\main.ide. Since you are specifying a project file, it has the .IDE extension.
 
2. The Target Type:
    Normally the target of the development process is a program or application. However, you can develop several other things with Borland C++ that are not exactly programs: various kinds of libraries and help files. You can also create an EasyWin program. These choices are listed in the Target Type list box. So click on EasyWin.

3. Platform and Model:
    Once you selected the EasyWin type, the Platform list box will now have only one choice: Windows3.x(16) . The Target Model (meaning the memory model to be used with this target) will let you choose from Small, Medium, Compact and Large. Choose Small.

4. Standard Libraries:
    The Standard Libraries group of buttons will change to reflect the choices you have made for the target and platform. Class Library and Run-time will be selected. You don't normally need Class Library, so uncheck it.

5. Initial Nodes:
    There is one more thing to do before leaving the New Project dialog. Click on the Advanced button.


 

In the Advanced Options dialog make sure the .cpp Node box is checked in the Initial Nodes group. We are going to be programming in C++, and .cpp Node specifies it. Uncheck the boxes with .RC or .DEF file.

6. The Project Window:
    When the New Project dialog is gone, another window with the title

Project: c:\temp\win3\bcpp40\main.ide
will appear at the bottom of the screen.


 
    In this window you will see an organization chart containing icons for main.exe and main.cpp. This chart shows the relationship between the various files in your program. The file that is your goal is the executable main.exe. Currently there is only one file that contributes to that result and that is main.cpp. This is the source file for your program.
    You can manipulate the files in the Project window directly by clicking with the right mouse button. This brings up a menu with various possibilities. For example, you can delete an unwanted node, or add a new one.
    If your source (.cpp) file already exists, you can now open it by selecting Open from the File menu.
    If you are writing a new program, select New from the File menu, and then Text Edit. A window will appear into which you can type the source file. Give this file the appropriate name (such as main.cpp) by selecting Save As from the File menu and filing in the name.
 
7. Multiple Programs:
    In a multifile project there is more than one source file. A source file with the same as the project, and located in the same directory, is automatically added to the project. However, you must tell IDE explicitly about files with other names. Here's how to add additional source files to a project.
    Open the project. If necessary, bring up the Project window by selecting it from the View menu. In the Project window, right-click on the node representing the .exe file. For example, if you want to add the bakery.cpp file to the main project, click on the main.exe node. Select Add Node from the resulting menu. A dialog box called Add A Project To List appears.

    The desired source files should appear on the list in this box. Select the one you want, bakery.cpp in this example. Then click the Open button. The dialog box will disappear, and you will see that a node representing the new file is now installed in the Project window. In main, the main.exe file is now dependent on both main.cpp and bakery.cpp
 


2. Running Your Program.

1. Compiling:
    In Borland C++ you can compile whatever source file is in active edit window (or selected in the Project window) by selecting Compile from the Project menu. A window called Compile Status will appear. An entry called Lines will change as compiling progresses. When the process is finished, the window will show that Warnings and Errors are 0.

2. Linking:
    To link your object file, select Make All from the Project menu. Now the Compile Status window shows one warning in the Link column. Clicking on OK will bring up the Message window, with the line

Linker Warning: no module definition file specified: using defaults
    You can ignore this warning. Windows programs including EasyWin program, need a definition file with details about constructing the program, but if you don't supply this file the linker will make one up for you.
    If you have only one file in you project, selecting Make All will simply link main.obj file to a library file. The result is an executable file called main.exe. However, the Make All selection actually performs a complex set of actions in more complicated situations. If there are several source files, it checks if any of them have been altered since the last Make, and if so recompiles them to bring them up to date. It doesn't compile object file that hasn't been altered. Finally, it links the object files, both old and new, to produce an executable file. Thus you don't actually need to perform compiling and linking as a two-step process. Simply select Make All from the Project file to both compile and link your program.

3. Running the Program:
    To execute the .exe file, select Run from the Debug menu.


3. Opening an Existing Project or File.

    To open a previously saved project, select Open Project from the Project menu and double click on the appropriate .ide file. Note that opening the source files is a separate operation. If it was open open when you closed the project, it will be opened automatically and installed in an edit window when you open the project. Otherwise, you'll need to select Open from the File menu and double click on the appropriate .cpp file in the box.
 
Files:
 
    Borland C++ generates quite a few files during the build process. You can see what these files are using the File Manager. Here's a brief description of what they do.

 
BACK TO TOP

Sanam Dadasheva


Back to CIS 22 home page