Basic Instructions for Turbo C++ 4.5

Note to early users of the computer lab: The Turbo C++ compiler in the computer lab is currently working well enough to complete the homework assignments. There may be some extra features of Turbo which are temporarily unavailable until the installation is complete. If you receive errors or warnings about Turbo not being able to write files, just click OK and otherwise ignore them. We should have these ironed out soon.

Compiling and Linking Homework 0

Here are basic instructions for compiling crrtest from Homework 0 in Turbo C++. I assume that you have successfully installed Turbo C++ on your PC or you are in the computer lab. These instructions are in the context of the first homework assignment, but they will be valid for later assignments with minor adjustments. The instructions might also be useful to those who choose not to use Turbo C++. I have written these instructions for Windows 3.11, but I assume that instructions for other versions of Windows will be very similar if not the same.

Screen snapshots are included to give you an idea of what your computer should look like after you have completed certain steps. The descriptions are complete without the images, but you may wish to use Netscape in the computer lab if your www browser does not support GIF images.

  1. Give the files the proper extension. This step is necessary because the extension is a flag to the compiler to enter C++ mode.
    If you are in the computer lab:
    Place the floppy disk containing the files,, and crr.h into the floppy drive. You must rename the files as crrtest.cpp and crr.cpp. (You can use Filemanager in Windows to rename the files.) You do not need to rename crr.h. (Remark: You can also specify the proper extension when you download the files.)

    You are allowed to move your files to the subdirectory labelled c:\docs on lab computers. Doing so will make things work much faster, but be careful. Don't forget to save your work on your floppy when you are done since you may lose it if someone else erases it (e.g., the system administrator cleans the drive). You should delete your work from this subdirectory to keep the computers clean and to prevent someone else from copying your work.

    If you are on your own computer:
    The programs compile much faster from the hard drive, so you might want to work from there. Create a the subdirectory in which you want to work. (The choice is yours, but you should create a directory separate from existing programs.) Move,, crr.h into this subdirectory. Rename files and as crr.cpp, crrtest.cpp , respectively.

  2. Using your favorite text editor (like NOTEPAD in Windows -- see Modifying the Code for more details), create the following file called crr.def:

    HEAPSIZE 1000
    STACKSIZE 45000

    Save this file on the floppy disk if you are in the computer lab, or in the same subdirectory as crr.cpp otherwise. It is not important that you know what this code means.

  3. Double click on the Turbo C++ icon to start the Integrated Development Environment (IDE). You should be at the main window in Turbo C++ with no other windows open. If there are open windows besides the main window, close them now so that we start on common ground.

    Here is a snapshot of the toolbar and the main window at this point.

    [image disabled]

  4. Select the PROJECT menu. Select NEW PROJECT. Use the BROWSE icon to select the floppy drive. Type crr.ide as the filename and click OK.

  5. Make sure that EasyWin[.exe] is highlighted. Click on the ADVANCED icon and make sure that there are no checkmarks on the .rc and .def buttons. Click OK.

    Here is a rough idea of what you should see at this point. [image disabled]

    Click OK once again.

  6. You should now be at the main window of Turbo C++. You should see a window with the title "Project a:\crr.ide" or something similar, depending on how you choose to organize your files. Right-click the mouse on crr[.exe] in this window. Select ADD NODE. Select crrtest.cpp. Click OK. Repeat this step to add the file crr.def to the project. (You will have to type this or use *.* to select it.) You should now see three nodes labelled crr[.cpp], crrtest[.cpp], and crr[.def] emanating from the crr[.exe] node.

  7. In the same window, right-click on crr.cpp. Select ADD NODE. Select crr.h. Click OK. Repeat this step, this with crrtest.cpp in place of crr.cpp. Now you should see a node labelled crr[.h] emanating from both the crr[.cpp] and crrtest[.cpp] nodes.

    Here is a snapshot of what you should see in your project window after having completed these steps.

    [image disabled]

  8. Finally we can compile the program! Click on the icon which displays a file and has the description Rebuild all files. Here is this icon:
    [image disabled]

    You should see a lot of activity and hear writing to the floppy drive or the hard drive, depending on where your source code is located. This may take a while. If there are no errors, a dialog box indicating "Success" should appear. Click OK. Now click the icon with the lightning bolt and the description Make and run current program. Here is what this button looks like:
    [image disabled]

    The CRR option pricing program should appear in a window. To stop the program, enter a negative stock price and close the window.

  9. If all goes well, you have successfully compiled your first C++ program using Turbo C++. You should begin thinking about how to change the programs according to the homework assignment. Please read the section "Modifying the Code" later in this document. If all did not go well, please check to make sure that you correctly followed the instructions. The next section lists symptoms of common mistakes and their possible corrections.


There is a chance that something will go wrong the first time, and you will almost certainly face problems sometime. There should be no errors in the original code since we have checked it on several platforms. However, you may have problems setting up the Turbo C++ IDE. Here are some potential pitfalls and their possible solutions. This list is specific to Turbo C++ 4.5, but it may be useful to those using other compilers. Even if you haven't made any mistakes, you might learn from the information below.
  1. I get an "Insufficient Memory" error when trying to start Turbo C++.

    You may have too many applications open when trying to start the compiler. The compiler is somewhat of a memory hog, so you might want to make it the only open application. If everything is closed but Turbo C++ yet you still get this message, you may need to exit and restart Windows to refresh the system resources. If this does not work and you are on a lab computer, check with a lab assistant. If you are on your own computer, check to make sure you that you have allocated sufficient virtual memory; consult your MS-DOS/Windows computer manuals. If this is not the problem, read the computer manuals on "Making more memory available" or consult someone in the computer lab.

  2. I get a linker error
    Undefined symbol (...) in library file C:\TCWIN\LIB\owlwi.lib 
    	in module winmain 

    You may not have selected EasyWin[.exe] in step 5. The EasyWin feature of Turbo C++ allows you to construct a Windows executable without knowing how Windows actually works. The selection Application[.exe] assumes instead that you have written a complete Windows application (with with message handlers and the like). This is something we will not do in class.

  3. Several problems which might have the same solution:
    • I get a linker warning
      No module definition file specified: using defaults.
    • I get a stack fault error when I try to run the program.
    • When I click on the lightning bolt, I get a blank screen. When I close the window, I am warned of a general processor fault.

    You may not have correctly typed crr.def in step 2 or did not add it to the project in step 6. Check these steps if you have not changed anything in the original code.

    If you have changed the code, then the variable MAXTERNODES may be too large. Memory allocated for arrays linked to this variable may exceed the 64K stack + heap + data group memory allocation allowed by a 16-bit compiler and straight-forward memory management. Try reducing MAXTERNODES to 3000 or so. If you have added new arrays of size MAXTERNODES, you may need to divide 3000 by the number of arrays. If you have a real need to access more memory, check out the "Which Compiler Should I Use" link. I have documentation on a advanced method which mitigates this problem in Turbo C++, but it is not recommended.

  4. I get a linker error similar to
    Undefined symbol crr::eurcall(...) in module crrtest

    The file crr.cpp may not have been properly added to the project in Step 6. If the symbol main() is undefined, you may not have added crrtest.cpp. It is also possible that you are using an undefined variable or a function which has not been prototyped. This error might also arise from not having renamed the *.cc files to *.cpp files.

  5. I am warned that there is a "possible use of foo before definition in function main". ("foo" substitutes for the name of an object, such as stockP in crrtest.)

    Be sure you have initialized all variables which need to be initialized.

  6. I made changes to parameters (like the riskless rate) in crr.h, and I clicked on the lightning bolt. The program runs fine, but I know the numbers are incorrect or are unchanged from previous runs.

    You may have incorrectly added crr.h in step 7. This step creates the dependence of crrtest.cpp and crr.cpp on crr.h.

    A mistake in this step is not typically fatal to creating an application, but it can produce unintended results. This error comes about because of an important feature in the "make" utility, which allows the compiler to recompile and link only what is necessary to update a program. This can save hours (or days!) of compilation time in complex programs. However, it is your responsibility to properly identify dependence among files in the IDE. You may notice that you can force the compiler to recompile everything by selecting the icon with the file and the description Rebuild all files
    [image disabled],
    but you should learn how to set up the IDE correctly. Failing to do so can produce programs which give wrong answers in critical situations, even though you have written correct source code!

  7. I get a message
    Linker fatal: crr.def syntax error 

    You may have mistyped something in crr.def.

  8. Although I do not get insufficient memory errors, the process is painfully slow.

    There are several potential problems. First, Turbo C++ 4.5 is likely to be slow when you have 4MB or less of RAM. Try minimizing the number of applications which are open at the same time. Be aware that there may be ``hidden'' programs, such as device drivers, which are run when you boot the computer. You may have to disable some of these to get more memory. Second, using the floppy drive slows things down a lot. Consider using the hard drive instead, but be careful if you are in the lab. Third, you might need to defragment your hard drive, especially if you haven't done so in a while. (Don't do this in the computer lab.) The problem is that Turbo C++ takes up quite a bit of space on the hard drive, and files can get so fragmented that the computer spends a lot of time moving to the files' locations. (I learned this the hard way.) Defragmenting with the /f option helps to solve this problem. See me if your computer complains that it does not have sufficient memory to do the defragmentation.

Experiment if you cannot find your error here; this is a good way to learn a programming language. If you get hopelessly confused, don't be afraid to delete all but the original files and redo everything. (This happens very often in programming!)

You may also experiment with the Turbo Debugger. The debugger gives you the ability to stop the program at specified locations to examine the values of the variables, among many other things. I do not generally use the debugger, but you may find it useful.

If you are hopelessly stuck, please describe your problem as much as possible and e-mail

Please realize that we may not be able to respond to your question before the assignment is due if you wait until the last possible minute to complete the assignment.

Modifying the Code

In this section, I will assume that you have successfully compiled and linked the original code in the first homework set. This section contains a guideline for modifying the code.
  1. Your first step is to choose a text editor. A good editor is packaged with Turbo C++; however, you are not required to use it. One nice feature of this editor is that it color-codes the source code for the C++ programs. After you get used to this feature, you may find that it will help you reduce typos or other common errors. Also, Turbo C++ automatically saves and backs up changes to your code so that you may not lose your work in an operating system crash. It is unlikely that this feature will work if you choose a different editor.

    There are other editors available to you, some of which provide support for programmers. For example, I prefer to use a clone of the UNIX vi editor called Vim. Using a program called ctags and Vim together, I can instantly move from function to function in C++ source code, even across multiple files. Vim has over 52 buffers for containing copied or deleted text and provides for immediate access to the MS-DOS command line. It allows you to write up to 26 macros and an unlimited number of abbreviations.

    The most important feature your compiler must have is the ability to save a document as pure text with no added symbols. MS-Works, MS-Word for Windows or DOS, and WordPerfect are examples of editors which you should avoid for writing C++ code. If you do decide to use such an editor, be sure to save the your work as a text file. Test the editor with small changes to make sure that it does not add symbols to your C++ code when you save files. It is extremely unlikely that your programs will compile if you save your work as anything but a text file.

  2. Once you have chosen an editor, the procedure for modifying files is simple. Make the appropriate changes, save the file, and choose the icon with the lightning bolt and the description Make and run the current program. Your program should run as you expect if you made the correct changes.

    To open files for editing in Turbo C++, double-click on the file in the project window. For example, I have opened and on my computer; here is a snapshot:

    [image disabled]

    Enter your changes in the appropriate window. It is generally a good idea to save your files before recompiling or running the program in case your operating system crashes, but Turbo C++ will usually save backups if you do not.