FAGClientDLL.cpp
Linking...
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in FAGClientDLL.obj
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in FAGClientDLL.obj; second definition ignored
Creating library Debug/FAGClientDLL.lib and object Debug/FAGClientDLL.exp
Debug/FAGClientDLL.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.FAGClientDLL.dll - 2 error(s), 1 warning(s)
Linking...
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in FAGClientDLL.obj
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in FAGClientDLL.obj; second definition ignored
Creating library Debug/FAGClientDLL.lib and object Debug/FAGClientDLL.exp
Debug/FAGClientDLL.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.FAGClientDLL.dll - 2 error(s), 1 warning(s)
Project Settings -> C/C++ -> Code Generation
用户运行库选Muitithreaded DLL
#include <afxdisp.h> statement.
you can solute it, by replace extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance, &LIBID_COMTESTLib);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE; // ok
}with class CXXXApp : public CWinApp
{
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestMFCApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL //{{AFX_MSG(CXXXApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};BEGIN_MESSAGE_MAP(CXXXApp, CWinApp)
//{{AFX_MSG_MAP(CXXXApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()CXXXApp theApp;BOOL CXXXApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance, &LIBID_TESTMFCLib);
return CWinApp::InitInstance();
}int CXXXApp::ExitInstance()
{
_Module.Term();
return CWinApp::ExitInstance();
}
结果编译竟然是正常的,后来我把DLLMAIN加上了,反而不正常了.编译时候就是上面写的错误,win32 dll 和mfc dll有什么区别吗?
CXXXApp::ExitInstance()相当于DLLMain里的case DLL_PROCESS_DETACH:
我的[email protected]