Dave's Brain

Browse - programming tips - nafxcwd lib dllmodul obj error LNK2005 DllMain already defined

Date: 2010feb19
Language: C/C++

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();
	}

What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2010, 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.