ATL中使用MFC的链接错误
用VC8.0向导 建了一个 Vc/ATL的工程 做Visual Studio 2005 的 PlugIn
在stdafx.h添加了 #include <afx.h> 后, 出现链接错误:
mfcs80ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in AddIn.obj
Creating library Debug/CodeGenerator.lib and object Debug/CodeGenerator.exp
Debug/CodeGenerator.dll : fatal error LNK1169: one or more multiply defined symbols found
找到一篇文章:
http://www.codeproject.com/buglist/linkererrors.asp?df=100&forumid=15354&exp=0&select=526635#xx526635xx
此牛人说:
I'm going to bet that when you created your ATL DLL project, you had the "Attributed" flag checked in the project settings, and didn't check the "Include MFC support" option before you had visual studio create the project. The easiest way to get around this is to just make a new project, and select the right options:
Create a new project, and set the project type to: "Atl Project"
When the ATL project wizard appears, click the "Application Settings" link to the left.
Uncheck "Attributed", and check "Support MFC". Then click "Finish" to let visual studio build out your project.
You will then be able to use your MFC functions without the linker error. An attributed ATL dll defines DllMain, and so does the MFC library, so you are getting a collision there. By using the method, Visual Studio will build your interface class from MFC instead of ATL, and thus will not specify that ATL should provide a DLL main. You could also adjust your compiler settings to make this happen, but I think you will be happier to just remake the project and let VS do all the work.
Good luck!
Nick.
重建工程 这个方法对我是没用的 因为这个是特别的ATL 且向导里面也没有地方让我选“属性”
问题是 我在源码里面 找了很久 久是没找到 他说的“属性”
还有一个外国SB说要建立一个MFC的DLL 导出标准函数 在ATL里面调用
这种方法我不想用
请问如何 才能让我 MFC ATL在一个工程里面用
谢谢