EVC平台下
将工程属性由use mfc in a static library 转化为 use mfc in a shared dll以后,出现100多个连接错误,错误提示大概如下:
Linking... 
uafxwce.lib(thrdcore.obj) : error LNK2005: "class CWinThread * __cdecl AfxBeginThread(unsigned int (__cdecl*)(void *),void *,int,unsigned int,unsigned long,struct _SECURITY_ATTRIBUTES *)" (?AfxBeginThread@@YAPAVCWinThread@@P6AIPAX@Z0HIKPAU_SECURITY_ATTRIBUTES@@@Z) already defined in MFCCE400.lib(mfcce400.dll) 
uafxwce.lib(thrdcore.obj) : error LNK2005: "public: virtual void __cdecl CWinThread::Delete(void)" (?Delete@CWinThread@@UAAXXZ) already defined in MFCCE400.lib(mfcce400.dll) 
都提示一些MFC函数在MFCCE400.lib中重复定义。但新建一个工程,将工程属性由use mfc in a static library 转化为 use mfc in a shared dll重新编译就不会有问题大侠们来救命哈,焦头烂额中啊原帖地址为:
http://topic.csdn.net/u/20090805/16/371de98d-b117-4c28-b8cf-2f4550187412.html

解决方案 »

  1.   

    When you use the Windows CE MFC library as a shared DLL, define _AFXDLL in your preprocessor definitions. This will cause your project to be linked with the Mfcce20.lib export library and the Mfcs42.lib static helper library. If your project supports ActiveX, it will also be linked with the Olece20.lib export library. When you use the Windows CE MFC library as a statically linked library,do not define _AFXDLL. If _AFXDLL is not defined, your project will be linked with the static MFC library, uafxwce.lib.
      

  2.   


    在我的原帖里说明了,需要添加支持Active X控件,需要包含头文件#include <afxdisp.h> 
    而afxdisp.h是需要定义_AFXDLL的
      

  3.   

    没仔细看,一定要加上_AFXDLL宏才行。
    你的问题是由于引入了静态链接MFC库uafxwce.lib,我查看了引入uafxwce.lib的代码,在afx.h中:
    #ifndef _AFXDLL
        #ifdef _DEBUG
            #pragma comment(lib, "uafxwced.lib")
        #else
            #pragma comment(lib, "uafxwce.lib")
        #endif
    #else      
        #ifdef _DEBUG
            #pragma comment(lib, "mfcs42d.lib")
            #pragma comment(lib, WCE_MFC_FILENAME(d.lib))
        #else
            #pragma comment(lib, "mfcs42.lib")
            #pragma comment(lib, WCE_MFC_FILENAME(.lib))
        #endif
    #endif
    很明显,是否链接uafxwce.lib是由_AFXDLL控制,而你定义了宏,所以不可能会被链接到工程。我猜测有一个可能,问题由于你的工程没有重新rebuild all导致,删掉你工程下的pch,pdb文件再rebuild all一次试试。
      

  4.   


    首先感谢这位大侠的热心,这个工程rebuild all了无数次了,错误还是一样
    如果这些错误是由“静态链接MFC库uafxwce.lib”引起,那根据你给的这段代码,定义了_AFXDLL的话,这个库uafxwce.lib是不会被链接到工程啊
      

  5.   

    这个原因是,因为你的一些定义引起的,因为你创建的时候,选的什么,对应的定义已经产生了,你改后,那些定义不会去掉,所以会有问题,还有function使用方面也有一些注意的~~这问题有点复杂
      

  6.   

    感谢13楼的conry,经过测试确实有一个第三方的库静态编译了,去掉这个库就编译通过啦非常感谢!