在WIN32 DLL中使用MFC库遇到的问题
2014-01-01 23:08
411 查看
今天写了一个DLL,DLL中用到的一个类里用到的MSXML的COM组件,所以在DLL中要包含afx.h头文件,也就不可避免的要用到MFC的类库了,但在编译时出现了错误:mfcs42d.lib(dllmodul.obj) : error LNK2005:_DllMain@12 already defined in NetDriverConfig.obj,
在http://topic.csdn.net/t/20010911/10/281452.html 处的贴子里找到了以下回答,试了一个原来是文件里定义的对象与mfcs42d.lib有冲突,加了命名空间后问题解决。还不知道DLL能不能使用,明天试一下再说了!
Linker Tools Error LNK2005
symbol already defined in object
The given symbol, displayed in its decorated form, was multiply defined.
Tips
One of the following may be a cause:
The most common cause of this error is accidentally linking with both the single-threaded and multithreaded libraries. Ensure that the application project file includes only the appropriate libraries and that any third-party libraries have appropriately created single-threaded or multithreaded versions.
The given symbol was a packaged function (created by compiling with /Gy) and was included in more than one file but was changed between compilations. Recompile all files that include the symbol.
The given symbol was defined differently in two member objects in different libraries, and both member objects were used.
An absolute was defined twice, with a different value in each definition.
Linker Tools Error LNK1169
one or more multiply defined symbols found
The build failed due to multiple definitions of one or more symbols. This error is preceded by error LNK2005.
The /FORCE or /FORCE:MULTIPLE option overrides this error.
-------------------------------------------------------------------------------------------------------------------------------------------------
今天又看了下发,发现在WIN32 DLL中使用MFC类库是会存在问题,原因是在MFC/src/DLLModul.cpp 文件中已经声明了DLLMain()函数,所以就不能在项目文件中再声明 DllMain(),否则就会出现如上所示的链接错误。所以在WIN32 DLL中使用MFC类库的话可以不声明DLLMain()函数,如果有操作要放在DLL加载时初始化的话就从CWinApp派生一个类,在项目文件里声明这个对象,在这个CWinApp类的InitInstance()成员函数中做初始化工作
在http://topic.csdn.net/t/20010911/10/281452.html 处的贴子里找到了以下回答,试了一个原来是文件里定义的对象与mfcs42d.lib有冲突,加了命名空间后问题解决。还不知道DLL能不能使用,明天试一下再说了!
Linker Tools Error LNK2005
symbol already defined in object
The given symbol, displayed in its decorated form, was multiply defined.
Tips
One of the following may be a cause:
The most common cause of this error is accidentally linking with both the single-threaded and multithreaded libraries. Ensure that the application project file includes only the appropriate libraries and that any third-party libraries have appropriately created single-threaded or multithreaded versions.
The given symbol was a packaged function (created by compiling with /Gy) and was included in more than one file but was changed between compilations. Recompile all files that include the symbol.
The given symbol was defined differently in two member objects in different libraries, and both member objects were used.
An absolute was defined twice, with a different value in each definition.
Linker Tools Error LNK1169
one or more multiply defined symbols found
The build failed due to multiple definitions of one or more symbols. This error is preceded by error LNK2005.
The /FORCE or /FORCE:MULTIPLE option overrides this error.
-------------------------------------------------------------------------------------------------------------------------------------------------
今天又看了下发,发现在WIN32 DLL中使用MFC类库是会存在问题,原因是在MFC/src/DLLModul.cpp 文件中已经声明了DLLMain()函数,所以就不能在项目文件中再声明 DllMain(),否则就会出现如上所示的链接错误。所以在WIN32 DLL中使用MFC类库的话可以不声明DLLMain()函数,如果有操作要放在DLL加载时初始化的话就从CWinApp派生一个类,在项目文件里声明这个对象,在这个CWinApp类的InitInstance()成员函数中做初始化工作
相关文章推荐
- C# 调用 C++ 写的Dll 遇到的问题(调用DLL 自动退出) win32已停止工作
- NetDiskdll.dll中MD5File函数使用时遇到的问题
- Win32dll工程添加MFC窗口类之后遇到的各种问题
- 刚才遇到了关于C#使用外部DLL函数上的char*的问题。
- Win32 下使用 GDI+ 遇到的问题.
- 在使用ILSpy对c# dll进行反编译时遇到的问题及处理方式
- 使用WinDbg调试Silverlight中遇到“Failed to find runtime DLL (clr.dll), 0x80004005”问题的解决方法之一
- 使用ICSharpCode.SharpZipLib.dll遇到的问题——Could not load file or assembly 'ICSharpCode.SharpZipLib……
- 在dll中使用FastReport会遇到以下内个问题
- 关于用c生成的dll在使用其他供应商的工具创建可执行模块时遇到的一些问题
- 关于win32程序如何使用mfcdll的问题.
- .net 使用AjaxControlToolkit.dll 遇到的"Sys"未定义问题
- 使用Microsoft.SmartDevice.Connectivity.dll中遇到的问题
- 使用 VS2010 开发 MapXtreme2008 遇到的问题 无法复制文件“C:\Program Files\Common Files\MapInfo\MapXtreme\7.0.0\Compiler.DLL”,原因是找不到该文件
- 使用ACE日志策略时遇到的问题:DLL::open failed for ACE: Error: check log for details Unable to find service 'Logger'
- Win32 下 使用CMarkup类遇到的问题
- vs2008中的MFC用共享DLL和静态中使用MFC,遇到的问题
- DLL在跨平台之间的使用中遇到的问题(以delphi中开发的dll,在vc中使用为例)
- 在使用一个全局底层键盘钩子dll时遇到的问题
- WIN32 DLL中使用MFC的问题