Dave's Brain

Browse - Programming Tips - How can I avoid this error: nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MyThing.obj

Date: 2010feb19
Language: C/C++
OS: Windows

Q.  How can I avoid this error: nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MyThing.obj

A.  This happens when you have a DllMain in a DLL that uses MFC.
MFC has its own DllMain (in nafxcwd.lib).

If you are going to use MFC you can't have a DllMain.

If you simply want to get the instance handle you can use

hHandle = AfxGetInstanceHandle();
in your DLL. To do more you need to define your own class based on CWinApp and do initialization in InitInstance();
class CMyClass : public CWinApp { public: virtual BOOL InitInstance(); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.