HOWTO: Create a Static Library with Visual Workbench

Last reviewed: September 30, 1997
Article ID: Q102677
The information in this article applies to:
  • The development environment, included with: - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52 - Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, 2.1, 4.0, 5.0

SUMMARY

When you build a static library (.LIB file) with Visual Workbench, the default project options build a static library for the Microsoft Windows operating system. The documentation does not explicitly indicate this fact.

By default, the 16-bit versions of Visual Workbench listed above specify the /GA compiler option switch when they build a static library, and the 32- bit development environment includes the /D "_WINDOWS" compiler option switch. Each of these options defines the _WINDOWS symbol for all source files in the project.

To build a static library for the MS-DOS operating system with 16-bit Visual Workbench or a console static library with the 32-bit development environment, follow the appropriate steps listed below:

Building a Static Library for MS-DOS with 16-bit Visual Workbench

When you build a static library for MS-DOS, you must remove the /GA compiler option switch. To do so, choose Project from the Visual Workbench Options menu, then choose the Compiler button. Select the Windows Prolog/Epilog category and choose the None option in the "Generate Prolog/Epilog For" box. Then choose OK to change the project options.

NOTE: Removing the /GA leaves no preprocessor definition for the target platform. Specifically, removing /GA also removes /D "_WINDOWS", since /D "_WINDOWS" is forced by /GA. If you remove /GA, you also need to add /D "_DOS", or else compilation errors will occur in the preprocessing of standard headers, such as AFX.H.

Building a Console Static Library with Visual Workbench 1.1

When you build a console library, you must remove the /D "_WINDOWS" option from the list of compiler options. To do so, choose Project from the Visual Workbench Options menu, then choose the Compiler button. Select the Preprocessor category and remove the string _WINDOWS from the "Symbols and Macros to Define" edit control. Then choose OK to change the project options.

Building a Console Static Library with Visual Workbench 2.x and 4.0

When you build a console library, you must remove the /D"_WINDOWS" option from the list of compiler options. To do so with the Visual WorkBench version 4.0, choose Settings... from the Build menu; to do do with the Visual WorkBench version 2.x, choose Settings from the Project menu. For both versions, choose the C/C++ tab. In the Visual WorkBench version 4.0, select the General category; in the Visual WorkBench version 4.0, select the Preprocessor category. For both versions, remove the string _WINDOWS from the "Preprocessor Definitions" edit control. Choose OK to save the new project options.

NOTE: 32-bit Import libraries are created by LINK when it builds a program or DLL that contains exports. 16-bit Import libraries are build using IMPLIB.

Keywords          : VwbIss kbfasttip
Version           : WINDOWS:1.0,1.1,1.5,1.51,1.52;WINDOWS NT:1.0,2.0,2.1,4.0,5.0
Platform          : NT WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.