Computing Concepts with C++ Essentials/Big C++

Compiler and Tool Help

Microsoft Visual C++ 6.0

If you install this compiler from the original CD ROM, be sure to install the latest patches from the web. The patches correct many (but not all) of the known bugs in the product. 

If you want to compile programs that use the Time/Employee classes or CCC graphics, then you need to download and unzip the programs for this book from http://horstmann.com/ccc.html . Unzip all files into a directory such as c:\CCCBook. If you choose a different installation directory, modify these instructions accordingly.

Compiling a simple program from the book

For simple programs, you can just load a file into Visual C++ and select the Build | Build menu option. The compiler will ask you if you would like to create a default workspace. Click on Yes. Then select Build | Execute from the menu to run the program. Select File | Close Workspace before you start another program.

Preparing Microsoft Visual C++ 6.0 for the CCC library

You must follow these steps once if you want to compile programs that use the Time/Employee classes or CCC graphics.
  1. Select the Tools|Options menu option from the main menu of the Developer Studio
  2. Click on the Directories tab.
  3. Make sure the Platform choice is set to Win32 and the Show directories for choice is set for Include files.
  4. Double-click on the empty rectangle at the bottom of the Directories list.
  5. Type the location of your CCC files, such as c:\CCCBook\cccfiles, or click on the ... icon and choose the directory. (This must be the directory that contains ccc_ansi.cpp and so on.)
Now you are ready to create a project, as described in the following task.

Creating a project with Microsoft Visual C++ 6.0

  1. Select the File | New ... menu option from the main menu of the Developer Studio
  2. Now you need to make your first decision. Are you building a console application or a graphics application? A console application reads keystrokes and displays text in a console window (or "DOS window), typically with a black background. For example, the "Hello, World" program is a console application. A graphical application displays graphical shapes in a regular window, with a white background.
  3. In the same dialog, in the Project Name field, enter a name for your project (such as MyProject).
  4. Still in the same dialog, in the Location field, select the working directory for your files (such as c:\MyHomework). You can click on the ... icon to pick a directory, or you can type in the full path name.
    Warning: If you pick the directory by clicking on the ... dialog, the compiler doesn't place the files into the directory that you picked. Instead, it places them in a subdirectory with the same name as the project (for example, c:\MyHomework\MyProject).
  5. Still in the same dialog, click Ok.
  6. In the resulting dialog box, Select An empty project and click Finish
  7. In the resulting "Project Information" dialog, click Ok
  8. Now you need to make another decision. Do you want to start with a new file, or do you want to compile an existing file (say, one of the examples).
  9. Are you using the Time or Employee classes from the book? If so, you need to select the Project | Add to project | Files ... menu option and add ccc_time.cpp or ccc_empl.cpp (in the c:\CCCBook\cccfiles directory)
  10. Are you using the CCC graphics library? If so, you need to select the Project | Add to project | Files ... menu option and add ccc_msw.cpp and ccc_shap.cpp (in the c:\CCCBook\cccfiles directory)
  11. When you are ready to build your program, select the Build | Build menu option from the main menu of the Developer Studio.
  12. If there are error messages in the bottom window, double-click on each message to go to the location of the error in your file. Fix the errors and build your program again.
  13. When your program has been built succesfully, select theBuild | Execute menu option from the main menu of the Developer Studio.
  14. If you need to debug your program, select the Build | Start Debug | Step Into menu option from the main menu of the Developer Studio.
  15. If you want to start a new project, select the File | Close workspace menu option from the main menu of the Developer Studio.

Compiling wxWindows Programs in Microsoft Windows

Note that the wxWindows library has changed the name to wxWidgets, but the current stable version (2.4.2) still uses the wxWindows name.

You need to carry out the following steps once.
  1. Download the Windows version of the library. Pick the file wxMSW-2.4.2.zip, save it to your computer and extract it into the root directory. You should now have a c:\wxWindows-2.4.2 directory.
  2. Open a DOS shell. (Start -> Run, type cmd, and click Ok).
  3. Type the following commands:
    set WXWIN=c:\wxWindows-2.4.2
    "c:\Program Files\Microsoft Visual Studio\vc98\bin\vcvars32.bat"
    c:
    cd \wxWindows-2.4.2\src\msw
    nmake -f makefile.vc
    (You may need to adjust the directory of vcvars32.bat if you did not choose the default location for Visual Studio.)
  4. Wait until nmake is finished. To confirm that all is well, check that the file c:\wxWindows-2.4.2\lib\wxmswd.lib has been created.
Now you are ready to compile individual programs. For each program, follow these steps:

First, you make a resource file. That is a file that has the same name as your program but extension .rc. It needs to contain the single line
#include "wx/msw/wx.rc"

Next, run the batch file

c:\VisualStudio\vc98\bin\vcvars32.bat

to set up the environment for the Microsoft tools. (You may need to adjust the directory of vcvars32.bat if you did not choose the default location for Visual Studio.)

Then run

nmake /f c:\wxWindows-2.4.2\src\makeprog.vc WXWIN=c:\wxWindows-2.4.2 PROGRAM=program name OBJECTS=object file(s)

For example,

nmake /f c:\wxWindows-2.4.2\src\makeprog.vc WXWIN=c:\wxWindows-2.4.2 PROGRAM=button OBJECTS=button.obj