Basic Instructions for Symantec C++ Version 7

Symantec 7.0 seems to be a very good Windows compiler with some nice features, including command-line support. This will substantially simplify the instructions for first-time C++ users. I recommend that you select the option "Use Command Line Tools" during the installation so that the command-line option is available to you. You should also consider selecting the option "Use Windows Hosted Environment" so that you can use the Integrated Development and Debugging Environment if you like it better.

Installation Notes

The install program gives you several options when installing Symantec C++. I chose the typical installation with the 32-bit and 16-bit options. (I have Windows 3.11. You may want to choose just the 32-bit if you have Windows 95.) I chose to do the "CD and Hard Disk" installation to save space. The instructions warn that this may slow down compilation, but it's still plenty fast for our computational finance programs. You can always reinstall later if you notice a slowdown.

One thing I noticed was that the CD install puts around 40MB of help files on the hard-drive and leaves include files and the libraries on the CD. I deleted all the help files from my hard-drive and copied the include and lib subdirectories to the hard-drive. This saves about 32MB of hard-drive space and means that you will have to access the CD less during compilation (a good thing). This will make your help files inaccessible from the IDDE, but you can run them from the CD by double-clicking on them.

If you have further problems with the installation, check the ``Getting Started Guide'' included with the CD. It has a detailed troubleshooting section. If you need further assistance, please contact me.


Compiling and Linking Homework 0

I assume that you have successfully installed Symantec C++ on your PC or you are using the Symantec C++ in the lab. These instructions are for compiling and linking 32-bit DOS programs. You will find that compiling and linking are somewhat easier in Symantec relative to Turbo C++ because we can use the command line.

General Note: I am not sure whether the homework problems can be compiled easily into a Windows (3.x,NT,95) program. My intuition is that they cannot because our programs do not have code which tells it how to interact with the Windows operating system. The ``EasyWin'' feature in Turbo C++ adds this extra code, so the executable compiled there is indeed a full-fledged Windows program. At this time, I do not know if Symantec C++ has a similar feature.

Note to Windows 95 users: I am almost certain (and have been told) that the instructions below will work for you; you only need to access the DOS command line. My understanding is that you can do this directly in Windows 95 or you can reboot in DOS mode. Please let me know if you have problems.

Screen snapshots are included to give you an idea of what you should see at various steps. The descriptions are complete without the 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 crrtest.cc, crr.cc, 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.

    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.cc, crrtest.cc, crr.h into this subdirectory. Rename files crr.cc and crrtest.cc as crr.cpp, crrtest.cpp , respectively.

  2. Open a MS-DOS command window. Change directories to the subdirectory in which you have placed the source code. Enter the following commands.

    sc crrtest.cpp -mx -c -ocrrtest.obj
    sc crr.cpp -mx -c -ocrr.obj
    sc -mx crrtest.obj crr.obj -ocrrtest.exe
    
    The first two commands compile crrtest.cpp and crr.cpp without linking them. (This is what the -c option tells us.) The output is placed in files crrtest.obj and crr.obj. The -mx option compiles in DOS extender code (discussed below). The third command links the object files and the DOS extender. The name of the executable will be crrtest.exe .

    Here is a snapshot of my screen after I have entered these commands.

    [image disabled]

  3. You are now ready to run the program. Simply type
     crrtest.exe
    at the DOS prompt. Enter a negative stock price when you are finished.


Troubleshooting

You are much less likely to make mistakes using the command line with Symantec than if you were using Turbo C++. However, potential problems could arise later when you modify this or later homework sets. Here is a problem which is very likely to arise sometime.
  1. When I run the executable crrtest.exe, I get a message whose first few lines looks like
    INTERRUPT 0CH, STACK FAULT
    error code = 0000
    eax = 00000000     esi=7E4B567F     flags = 0286     ds = 00CF
    	. 		.		.		.
    	.		.		.		.
    	.		.		.		. 
    

    The problem is that, even though you are compiling in 32-bit mode, the memory requirements of the program exceed the default amount of memory allocated to it.

    One solution is to allocate more memory. To do this, use your favorite text editor to add the following lines to crrtest.cpp between the statement which includes iostream.h and crr.h.

    //The following lines set the stack size to 200KB.
    //
    #include <dos.h>
    unsigned _stack = 204800;
    //
    
    It is important to use the underscore in "_stack". Also notice that this portion of code is most likely nonportable since it includes the header file dos.h.

    Here is a snapshot of my editor in which I have highlighted the new code.

    [image disabled]

    The reason that this works is because we have compiled and linked in the DOS extender code by using the option -mx above. This code enables the program to access all available extended memory (up to 4 gigabytes) if you have an extended memory manager or the amount of available conventional memory otherwise (up to 640KB). The small amount of extra code we must enter tells the program to allocate 200KB. You can set this much higher if you wish, but you are limited to the amount of RAM plus virtual memory on your computer.

    The DOS extender also places the processor in protected mode, which gives you some crash protection. For more information, search for DOSX in the Symantec C++ online help.

  2. Something which is not really a problem but which may become an issue is our choice of options during the compiling and linking. The options chosen above are minimal to get us going, but you may wish to include other options later. I will discuss this at a later time if there is an interest.

  3. (Added 1/24/95) Here are some questions asked by a student and my replies. The student ultimately was successful in compiling a DOS program using the IDE (or IDDE) of the Symantec compiler (SC).

    I have a project, crr.prj, opened, and it has the three files in it, but they do not appear to be organized in any particular way. I played around with the "heirarchy" feature trying to organize files in the same way you did, but was unable to figure out the function.

    SC automatically recognizes the dependence of crrtest.cpp and crr.cpp on crr.h. Turbo C++ (TC) should but doesn't, so that is why it is important in TC but not here. In the IDDE in SC, you should have crrtest.cpp and crr.cpp in the "Project" window, and the compiler will insert crr.h itself later.

    I tried to compile the group of three files (actually four with crr.def)...

    You do not need to write the crr.def file for the SC IDDE since it writes one for you. The maximum stacksize is set during the linking stage for DOS or DOSX programs.

    I got an error in a file called crrtest.obj which said

     
    		Symbol Undefined __acrtused_winc
    

    You most likely have the IDDE set so that it compiles some type of Windows executuable (Win 3.x, Win32, or Win 95). You will probably need to set it to compile a DOS or a DOSX executable. This is an option you have when you set up the project, or you can change it under Project...Settings. The reason is that a Windows program needs more information than we give it. For instance, the program must know how to interpret a mouse click or a command to paint a resized window. This is difficult and off-topic, so it is best to just compile as DOS or DOSX. There may be a feature in SC which lets you compile a generic program into a Windows program (by automatically inserting the appropriate code), but I don't know of it.