When you use MFC in a static library to cause library conflicts, find one or more symbols with multiple definitions.

Source: Internet
Author: User

It is okay to use MFC in the shared library for the project. The following problem occurs when you use MFC in a static library.

1> msvcrtd. lib (ti_inst.obj): error LNK2005: "private: _ thiscall type_info: type_info (class type_info const &)"(?? 0type_info @ AAE @ ABV0 @ Z) has been defined in libcmtd. lib (typinfo. obj)

1> msvcrtd. lib (ti_inst.obj): error LNK2005: "private: class type_info & _ thiscall type_info: operator = (class type_info const &)"(?? 4type_info @ AAEAAV0 @ ABV0 @ Z) has been defined in libcmtd. lib (typinfo. obj)
1> msvcrtd. lib (MSVCR100D. dll): error LNK2005: _ wcsrchr has been defined in libcmtd. lib (wcsrchr. obj)
1> libcmtd. lib (crt0init. obj): warning LNK4098: the default library "msvcrtd. lib" conflicts with other libraries. Use/NODEFAULTLIB: library

1> G: \ MFCProjiect \ VideoLog \ Debug \ VideoLog.exe: fatal error LNK1169: locate one or more symbols with multiple definitions

I checked it online and said that a default library should be ignored.

After libcmtd. lib is ignored

1> Strmbasd. lib (mtype. obj): warning LNK4075: Ignore "/EDITANDCONTINUE" (due to the "/OPT: ICF" Specification)
1> uafxcw. lib (appcore. obj): error LNK2001: an external symbol that cannot be parsed ___ wargv
1> uafxcw. lib (appcore. obj): error LNK2001: external symbol that cannot be parsed ___ argc
1> G: \ MFCProjiect \ VideoLog \ Release \ VideoLog.exe: fatal error LNK1120: 2 external commands that cannot be parsed
1>
1> generation failed.

After msvcrtd. lib is ignored

1> Strmbasd. lib (mtype. obj): warning LNK4075: Ignore "/EDITANDCONTINUE" (due to the "/OPT: ICF" Specification)
1> Strmbasd. lib (wxdebug. obj): error LNK2001: external symbol that cannot be parsed _ imp ___ vsnwprintf
1> Strmbasd. lib (wxdebug. obj): error LNK2001: external symbol that cannot be parsed _ imp ___ vsnprintf
1> G: \ MFCProjiect \ VideoLog \ Release \ VideoLog.exe: fatal error LNK1120: 2 external commands that cannot be parsed
1>
1> generation failed.

Solution:

Define _ afxdll, project-> seting-> C/C ++-> Preprocessor-> DEFINE _ afxdll in Preprocessor. If the error message "Fatal error c1189: # error: please use the/MD switch for _ afxdll builds" appears, modify the following code: c/C ++-> code generation-> multithread DLL (Implementation/MD option)

Solve the problem and close the work.

Or use MFC in the shared library.

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.