VS Error Error LNK2005: _dllmain@12 already defined in MSVCRTD.lib (dllmain.obj)

Source: Internet
Author: User
Tags switches

Link error: Wrong error LNK2005: [email protected] already defined in MSVCRTD.lib (dllmain.obj) e:\ customer issues \w_ Wang Peng \eventlibtest_ tibrvalternative_multienv-4-0.3 the Dtssysevent.xml as a separate parameter to each environment \eventlibtest_tibrvalternative_multienv\win32 \APPFL \eventlibmultienvdll\mfcs100d.lib (dllmodul.obj) eventlibmultienvdll (Visual Studio )
Workaround:Project-"Properties-" Configuration Properties-"c/c++/preprocessor, remove _usrdll in the preprocessor definition
In addition:the meaning of common preprocessor settings: http://blog.csdn.net/honker110/article/details/6120810

Common compilation Parameters The VC will always define "WIN32" when establishing a project. The console program defines "_console", otherwise "_windows" is defined. The DEBUG version defines "_DEBUG", and Release edition defines "ndebug" compiler constants related to MFC DLLs include: _windll represents a DLL to be used in MFC _usrdll represents a user DLL (relative to the MFC extension DLL) _AFX DLL represents the regular DLL that uses the MFC dynamic link library _afxext to make an MFC extension DLL so: regular, statically linked to MFC _windll,_usrdll regular, U Sing the shared MFC dll _windll,_usrdll,_afxdll Extension dll _windll,_afxdll,_afxext


Building Your DLL

When compiling regular DLLs this statically link to MFC, the symbols "_usrdll" and "_windll" must is defined. Your DLL code must also is compiled with the following compiler switches:
/d_windll signifies the compilation is for a DLL/d_usrdll specifies your is building a regular DLL

When compiling regulardlls this statically link to MFC, the symbols "_usr DLL" and "_windll" must is defined. Your DLL code must also be compile dwith the following compiler Switches:when compiling regular DLLs that Dynamicallylink To MFC, you must define t he above symbols and use the above compilerswitches. Additionally, the SY mbol "_afxdll" must be Definedand your DLL code must be compiled with:/d_afxdll     SPECIF IES that is building a regular DLL that Dynamicall y links to Mfcthe interfaces (APIs) between the application and th e DLL must beexplicitlyexported. It is recommended so define your interfaces to being LOWBANDW idth, sticking to C interfaces where possible. More direct C interfaces Areeasi er to maintain than more complex C + + classes. Place your APIs in aseparate header that can is included by both C and C++files (that's the You won ' Tlimit your DLL customer s to C + + programmers). Se e The header ScreenCap.h in theMFC Advanced Concepts sample Dllscreen Cap For an example. To export yourfunctions, enter them in Theexportss ection of your moduledefinition file (. DEF) or Include__declspec (Dllexpor t) on yourfunction definitions. Use__declspec (dllimport) to import thesefunctions into the client executable. You must add Theafx_manage_statemacro @ The beginning of all the E xportedfunctions in regular DLLs that dynamically link To MFC to set the Curr Ent modulestate to the one for the DLL. This was done by adding the followingline of Codeto the beginning of functions exported from the Dll:afx_manage_state (afxge Tstaticmodulestate ()) Winmain->dllmainthe MFC Library defines the standard Win32dllmain entry point that Initializ es y Ourcwinappderived object as in a normal MFC application. Placeall dll-specific initialization in theinitinstancememberfunction as in a normal MFC application.  proven feasible   transferred from http://blog.csdn.net/tian_jinping/article/details/14168919   or use the following method, yes MFC library precedes Msvcrtd.lib link     [email protected]  already in &NBsp MSVCRTD.lib (dllmain.obj)   defined in
VC2005 Workaround:
1) Debug Version:
Project-Properties-linker-Input: Ignore input mfc80d.lib;mfcs80d.lib in a specific library
Project-Properties-linker-Additional dependencies: Mfc80d.lib;mfcs80d.lib
can guarantee mfc80d and mfcs80d before MSVCRTD.lib link, OK, success
2) Release version
Unlike the debug version, it is Mfc80.lib;mfcs80.lib

VS Error Error LNK2005: [email protected] already defined in MSVCRTD.lib (dllmain.obj)

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.