MFC Program (Using MFC in Static Library) Problems

Source: Internet
Author: User
Keywords static library mfc program mfc dll
Basic knowledge:

When configuring "Use of MFC" in the project's configuration properties, the options are different: If you select "Use MFC in a shared DLL", the compiled program does not include the MFC library, so the file will be small, but if the program is directly When you move to a machine that has not installed MFC, you may not find the MFC DLL. If you select "Use MFC in a static library", the compiled program directly includes the library that calls the MFC. The file may be It will be bigger, but it can be moved directly to other machines.

Problems encountered:

There was no problem compiling when selecting "Use MFC in shared DLL", but there was a problem with library redefinition when selecting "Use MFC in static library" instead. . .

Solution: (3 steps)

First configure MFC to use MFC in a static library:

Properties-> General-> MFC use, select "Use MFC in static library"

Then, configure the runtime:

Properties-> C / C ++-> Code Generation-> Runtime Library, select "Multithreaded (/ MT)"

Finally, add the two library files nafxcw.lib and libcmt.lib to the additional dependencies: (Note: The library nafxcw.lib must precede the library libcmt.lib, the former is the mfc static link library and the latter is the c runtime library)

Properties-> linker-> input-> additional dependencies, add nafxcw.lib and libcmt.lib

OK! !! !!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.