nafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined问题解决

本文介绍如何解决在一个ATL DLL项目中引入MFC支持后遇到的编译错误,特别是关于_DllMain@12重复定义的问题,并提供了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如果开始用了一个ATL的Dll工程,然后为了在这个dll工程里面使用MFC,
在里面加入MFC支持
在stdafx.h的atlbase.h前面加入
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation extensions
那么就会出现错误,例如
nafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in LyricPlayerdll.obj
nafxcw.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in LyricPlayerdll.obj; second definition ignored
???? Creating library Release/IWOBZ_Lyric_Plugin.lib and object Release/IWOBZ_Lyric_Plugin.exp
Release/IWOBZ_Lyric_Plugin.dll : fatal error LNK1169: one or more multiply defined symbols found
解决办法:
工程->设置->C/C++->
Category:Preprocessor
Preprocessor definitions:
WIN32,NDEBUG,_WINDOWS,_MBCS,_USRDLL,MSGBOX_EXPORTS,_WINDLL,_AFXDLL中的_USRDLL,删除,就可以正确编译了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值