PRB: Can't Add Libs to Projects Created with Custom AppWizards

Last reviewed: October 6, 1997
Article ID: Q142788
The information in this article applies to:
  • The Custom AppWizard included with: - Microsoft Visual C++, 32-bit Edition, version 4.0

SYMPTOMS

Currently there is no support for manipulating project settings with a Custom AppWizard. Default settings are automatically used based on the type of application that the Custom AppWizard is based on, such as a console application, or an MFC application.

When constructing a Custom AppWizard that creates projects requiring additional libraries, it is necessary to add these libraries to your base project's link options. The problem is that creating a Custom AppWizard based on this base project, will not carry these custom link options over to the Custom AppWizard or the projects that this Custom AppWizard will generate.

RESOLUTION

To work around this limitation, you can add a pragma to one of the base project's header files to automatically link the project with a specific library. The pragma takes the following form:

   #pragma comment(lib, libname)

This places a library-search record in the object file. The libname parameter is the filename (and optionally the path) of the library you want the linker to search. Because the library name precedes the default library- search records in the object file, the linker searches for this library just as if you had named it on the command line. You can place multiple library-search records in the same source file; each record appears in the object file in the same order in which it is encountered in the source file.

This technique is identical to the technique used by MFC to link different types of MFC applications to the proper MFC libraries.

STATUS

This behavior is by design.

REFERENCES

For additional information on #pragma comment and on MFC's use of #pragma comment(lib, libname), query the Visual C++ Online Documentation using the following keywords:

   pragma, comment and lib
Keywords          : WizardIss
Version           : 4.0
Platform          : NT WINDOWS
Issue type        : kbprb


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


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: October 6, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.