Microsoft KB Archive/315535

From BetaArchive Wiki

Article ID: 315535

Article Last Modified on 9/12/2003



APPLIES TO

  • Microsoft Visual C++ 6.0 Service Pack 5



This article was previously published under Q315535

SYMPTOMS

When you try to rebuild the Visual C++ 6.0 C Runtime (CRT) Libraries (Static or Dynamic), you may experience some problems.

NOTE: Microsoft does not recommend rebuilding the CRT libraries. Microsoft may not be able to provide support for problems encountered when using rebuilt CRT libraries. You are not permitted to redistribute a rebuilt DLL with the same name used by Microsoft.

CAUSE

Makefile contains extra lines that cause errors during rebuild. Also, Makefile contains entries that are not valid.

RESOLUTION

To work around these errors, you must perform the following procedures:

Prerequisites

  1. The default installation of Visual C++ 6.0 does not install the CRT Source code directory. If you copy this directory manually from the installation CD-ROM, the directory tree will not be set properly. To install the CRT Source directory, follow these steps:
    1. On the Start menu, click Control Panel, and then click Add or Remove Programs.
    2. On the Currently Installed Programs list, click Microsoft Visual C++ 6.0.
    3. Click Change/Remove.
    4. In the Visual C++ 6.0 Setup dialog box, click Add/Remove.
    5. Click to select CRT Source Code.
    6. Click OK.
  2. Manually copy the following files from the Visual C++ installation CD-ROM to C:\Program Files\Microsoft Visual Studio\Vc98\Crt\Src:

    • Makefile
    • Makefile.inc
    • Makefile.sub


    NOTE: By default, Visual C++ is installed in the C:\Program Files\Microsoft Visual Studio folder. If you have installed Visual C++ in another location, make sure that you modify the path in all of the examples in this article.
  3. Change the file attributes of Makefile in C:\Program Files\Microsoft Visual Studio\Vc98\Crt\Src. To do this, follow these steps:
    1. In Windows Explorer, right-click Makefile, and then click Properties.
    2. Click to clear the check box for the Read-only file attribute.
    3. Click OK.
  4. In a text editor such as Notepad, make the following changes to Makefile:
    1. Change the three lines that start at line 38 so that they resemble the following sample code:

      #!if "$(V6TOOLS)"==""
      V6TOOLS=C:\Program Files\Microsoft Visual Studio\vc98
      #!endif  
                                  

      NOTE: Do not place double-quotes around the path designation.

    2. By default, line 331 appears as follows:

      RC_INCS=-I$(V6TOOLS)\include
                              

      If the name of your Visual C++ 6.0 installation directory contains spaces, then you must change line 331 by adding double quotes as follows:

      RC_INCS=-I"$(V6TOOLS)\include"
                              
    3. Search for every instance of Winver.h in Makefile, and then use the # symbol to comment out each line that includes Winver.h, as shown in the following sample code:

      # $(V6TOOLS)\include\winver.h \ 
                              
  5. Save your changes to Makefile, and then close the text editor.

Steps to Rebuild the Libraries

The environment must be configured properly before you can rebuild Makefile. To configure the environment, and then rebuild Makefile, follow these steps:

  1. If the Visual C++ environment variables are not set, then run the following batch file:

    C:\Program Files\Microsoft Visual Studio\Vc98\Bin\Vcvars32.bat

    NOTE: You may have to increase the environment space if your operating system is Microsoft Windows 95, Microsoft Windows 98, or Microsoft Windows Millennium Edition (Windows Me). For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

    248802 PRB: Vcvars32.bat Generates Out of Environment Message

    NOTE: If your computer has multiple versions of the C++ compiler (Cl.exe), run Vcvars32.bat to avoid unexpected results that may occur if you use the Visual C++ .NET compiler instead of the Visual C++ 6.0 compiler.
  2. At a command prompt, go to the C:\Program Files\Microsoft Visual Studio\Vc98\Crt\Src directory, and then run the command NMAKE. NMAKE builds all of the static and dynamic libraries. The libraries are placed in the C:\Program Files\Microsoft Visual Studio\Vc98\Crt\Src\Build\Intel directory.

    NOTE: You can run the command Bldnt.cmd instead of NMAKE. However, if you are building Makefile on a computer running Windows 95, Windows 98, or Windows Me, then you must run the batch file Bldwin95.bat instead of Bldnt.cmd.

By default, Makefile builds Msvcrt.dll as _sample_.dll, Msvcrtd.dll as _sampld_.dll, Msvcrti.dll as _sample_i.dll, and so on.

Makefile contains the following entries for the default names. If you want to change the default library names, change them in Makefile first. Be careful about your choice of names because some names have leading underscores and you must find the corresponding names in other files.

  • RETAIL_DLL_NAME=_sample_
  • RETAIL_LIB_NAME=_sample_
  • RETAIL_DLLCPP_NAME=sample_p
  • RETAIL_LIBCPP_NAME=sample_p
  • RETAIL_DLLIOS_NAME=sample_i
  • RETAIL_LIBIOS_NAME=sample_i
  • DEBUG_DLL_NAME=_sampld_
  • DEBUG_LIB_NAME=_sampld_
  • DEBUG_DLLCPP_NAME=sampld_p
  • DEBUG_LIBCPP_NAME=sampld_p
  • DEBUG_DLLIOS_NAME=sampld_i
  • DEBUG_LIBIOS_NAME=sampld_i

The following are the corresponding .rc and .def files with the default names:

  • Sampld_i.def
  • Sampld_p.def
  • Sample_i.def
  • Sample_i.rc
  • Sample_p.def
  • Sample_p.rc
  • _sample_.rc
  • _sample_.def
  • _sampld_.def

These files are located in the following directories:

  • C:\Program Files\Microsoft Visual Studio\Vc98\Crt\Src
  • C:\Program Files\Microsoft Visual Studio\Vc98\Crt\Src\Intel

You can rename these files to the names that you want. To do this, open the individual files, one at a time, and then change the corresponding names in the files to reflect the new names that you give to the files themselves. For example, if you want to change the default library name, Open _sample_.def. The file has the following line:

LIBRARY _SAMPLE_
                

Modify that line to the library name that you want to use, such as the following:

LIBRARY <I BRACKET="YES">mycrtlibname</I>
                

When you finish building the library, your application links to the resulting import library, mycrtlibname.lib.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual C++ .NET 2003.

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

234622 PRB: VC++ 6.0 Setup Does Not Copy the CRT Make Files


Keywords: kbbug kbnofix kbcrt kbcompiler KB315535