JMU JMU - Department of Computer Science
Help Tools
MS C/C++: The Command-Line Tools


1 Overview

The CS Department's Computer Labs are currently running version 6 of the MS Visual C++ development environment. As a result, you can develop C/C++ applications using either the Integrated Development Environment (IDE) or the command-line tools. We are only concerned with the command-line tools here.

2 Environment Variables

The command-line tools use several environment variables to locate executables, libraries, and include files. Hence, you must set these variables before you can begin.

If you don't have enough environment space then you may need to increase it. In Windows NT you can do this from the Control Panel. In Windows 95/98, on the other hand, you need to add a line like the following to the config.sys file (in the root directory):

    SHELL=C:\COMMAND.COM /E:4096 /P

Assuming that your root drive and directory is c:\ and that it contains a copy of command.com, everytime you boot your system a new copy of the command shell will be loaded with an environment size of 4096 and it will be made permanent.

2.1 The PATH to Executables

The PATH environment variable is used by the loader to locate executables entered at the command line. Hence, if you want to be able to run the C/C++ development tools from any directory, you need to add their location to the PATH.

In the CS Computer Labs the command-line tools are located in the directories:

    c:\Program Files\Microsoft Visual Studio\Common\MSDev98\bin

    c:\Program Files\Microsoft Visual Studio\VC98\bin

2.2 The Standard INCLUDE Search Path

The INCLUDE environment variable points to the directories that contain the standard "includes".

In the CS Computer Labs the standard "includes" are located in the directory:

    c:\Program Files\Microsoft Visual Studio\VC98\INCLUDE

2.3 The Standard Library Search Path

The LIB environment variable points to the directories that contain the standard libraries.

In the CS Computer Labs the standard libraries are located in the directory:

    c:\Program Files\Microsoft Visual Studio\VC98\LIB

3 Using a Batch File

You may want to create a .BAT file that sets everything up for you (especially if you don't always work in the CS Computer Labs). In the following example, an "intermediate" environment variable, msc_base, is used to increase its portability and flexibility.
    @echo off

    set msc_base=c:\Program Files\Microsoft Visual Studio

    
    rem Set the PATH to executables
    rem
    set PATH=%msc_base%\Common\MSDev98\bin;%msc_base%\VC98\bin;%PATH%


    rem Set the standard INCLUDE search path
    rem
    set INCLUDE=%msc_base%\VC98\INCLUDE;%INCLUDE%


    rem Set the Standard Library Path:
    rem
    set LIB=%msc_base%\VC98\lib;%LIB%
    

If you work at multiple locations you might want to remove the line:

    set msc_base=c:\program files\microsoft visual studio
    

and put it in a separate .BAT file (named, for example, lab.bat). Then, you could run the .BAT file that sets the msc_base environment variable appropriately for your current location before running the .BAT file that sets up everything else.

Alternatively, you might want to include an IF statement that sets the value of msc_base based on the first argument passed into the .BAT file. For example:

    @echo off

    rem Account for my location
    rem
    set msc_base=c:\Program Files\Microsoft Visual Studio
    if "%1"=="home"  set msc_base=e:\program files\DevStudio
    
    rem Set the PATH to executables
    rem
    set PATH=%msc_base%\Common\MSDev98\bin;%msc_base%\VC98\bin;%PATH%


    rem Set the standard INCLUDE search path
    rem
    set INCLUDE=%msc_base%\VC98\INCLUDE;%INCLUDE%


    rem Set the Standard Library Path:
    rem
    set LIB=%msc_base%\VC98\lib;%LIB%
    

Here, %1 refers to the first argument typed after the name of the .BAT file at the command line. So, if this file were named getready.bat, entering getready home would get things ready for home and anything else would get things ready for the lab.

4 Using the Command-Line Tools

For help using the command-line tools themselves, you might want to take a look at:

You also might want to take a look at the information about error and warning messages that Microsoft has made available. Click here for related information from another site.

Copyright 2019