我写一个程序,在编译时选择使用Use MFC in a Share Library一点问题都没有,但是选择使用Use MFC in a Static Library就不行了,我的程序用了CJ60LIB的库,在使用
Static Library编译时,出现如下警告:
warning C4275: non dll-interface class 'CButton' used as base for dll-interface class 'CCJButton'
warning C4251: 'm_cSize' : class 'CSize' needs to have dll-interface to be used by clients of class 'CCJButton'
warning C4251: 'm_rcItem' : class 'CRect' needs to have dll-interface to be used by clients of class 'CCJButton'
warning C4251: 'm_rcIcon' : class 'CRect' needs to have dll-interface to be used by clients of class 'CCJButton'
warning C4275: non dll-interface class 'CComboBox' used as base for dll-interface class 'CCJComboBox'
warning C4275: non dll-interface class 'CControlBar' used as base for dll-interface class 'CCJControlBar'
warning C4251: 'm_sizeMin' : class 'CSize' needs to have dll-interface to be used by clients of class 'CCJControlBar'
warning C4251: 'm_sizeHorz' : class 'CSize' needs to have dll-interface to be used by clients of class 'CCJControlBar'
warning C4251: 'm_sizeVert' : class 'CSize' needs to have dll-interface to be used by clients of class 'CCJControlBar'
warning C4251: 'm_sizeFloat' : class 'CSize' needs to have dll-interface to be used by clients of class 'CCJControlBar'
warning C4251: 'm_rectBorder' : class 'CRect' needs to have dll-interface to be used by clients of class 'CCJControlBar'
warning C4251: 'm_rectTracker' : class 'CRect' needs to have dll-interface to be used by clients of class 'CCJControlBar'
warning C4251: 'm_ptOld' : class 'CPoint' needs to have dll-interface to be used by clients of class 'CCJControlBar'
warning C4251: 'm_ToolTip' : class 'CToolTipCtrl' needs to have dll-interface to be used by clients of class 'CCJControlBar'
warning C4251: 'm_tabctrl' : class 'CTabCtrl' needs to have dll-interface to be used by clients of class 'CCJTabCtrlBar'
warning C4251: 'm_views' : class 'CList<struct TCB_ITEM *,struct TCB_ITEM *>' needs to have dll-interface to be used by clients of class 'CCJTabCtrlBar'
warning C4275: non dll-interface class 'CDockBar' used as base for dll-interface class 'CCJDockBar'还有很多这样的警告就不帖出来了,CJ60LIB的库做了一些修改

解决方案 »

  1.   

    CJ60LIB库链接必须也是用Use MFC in a Static Library,
    所以要重新编译CJ60LIB库
      

  2.   

    但是我对CJ60LIB进行静态编译时却出错
    C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxver_.h(130) : fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds
    Error executing cl.exe.
      

  3.   

    CJ609Lib.lib  --- release share
    CJ609LibStatic.lib -- release static 
    CJ609LibStaticd.lib -- debug static
    CJ609Libd.lib -- debug share你要连接不同版本的lib
      

  4.   

    我用CJ609LibStatic.lib -- release static 生成了LIB文件(只生成了LIB文件,没有DLL文件),然后
    把我的程序也用release static 去编译,但是通不过了,出现以下提示:
    LINK : warning LNK4049: locally defined symbol ""public: virtual __thiscall CCJControlBar::~CCJControlBar(void)" (??1CCJControlBar@@UAE@XZ)" imported
    LINK : warning LNK4049: locally defined symbol ""public: __thiscall CCJControlBar::CCJControlBar(void)" (??0CCJControlBar@@QAE@XZ)" imported
    LINK : warning LNK4049: locally defined symbol ""protected: static struct AFX_MSGMAP const  CCJControlBar::messageMap" (?messageMap@CCJControlBar@@1UAFX_MSGMAP@@B)" imported
    LINK : warning LNK4049: locally defined symbol ""protected: int __thiscall CCJControlBar::OnCreate(struct tagCREATESTRUCTA *)" (?OnCreate@CCJControlBar@@IAEHPAUtagCREATESTRUCTA@@@Z)" imported
    LINK : warning LNK4049: locally defined symbol ""public: int __thiscall CCJControlBar::IsHorzDocked(void)const " (?IsHorzDocked@CCJControlBar@@QBEHXZ)" imported
    LINK : warning LNK4049: locally defined symbol ""protected: void __thiscall CCJControlBar::OnWindowPosChanged(struct tagWINDOWPOS *)" (?OnWindowPosChanged@CCJControlBar@@IAEXPAUtagWINDOWPOS@@@Z)" imported
    LINK : warning LNK4049: locally defined symbol ""public: static struct CRuntimeClass const  CCJFrameWnd::classCCJFrameWnd" (?classCCJFrameWnd@CCJFrameWnd@@2UCRuntimeClass@@B)" imported
    LINK : warning LNK4049: locally defined symbol ""protected: static struct AFX_MSGMAP const  CCJFrameWnd::messageMap" (?messageMap@CCJFrameWnd@@1UAFX_MSGMAP@@B)" imported
    LINK : warning LNK4049: locally defined symbol ""public: virtual __thiscall CCJToolBar::~CCJToolBar(void)" (??1CCJToolBar@@UAE@XZ)" imported
    LINK : warning LNK4049: locally defined symbol ""public: virtual __thiscall CCJFrameWnd::~CCJFrameWnd(void)" (??1CCJFrameWnd@@UAE@XZ)" imported
    LINK : warning LNK4049: locally defined symbol ""public: __thiscall CCJToolBar::CCJToolBar(void)" (??0CCJToolBar@@QAE@XZ)" imported
    LINK : warning LNK4049: locally defined symbol ""public: __thiscall CCJFrameWnd::CCJFrameWnd(void)" (??0CCJFrameWnd@@QAE@XZ)" imported
    LINK : warning LNK4049: locally defined symbol ""public: class CImageList * __thiscall CCJControlBar::SetBtnImageList(class CImageList *)" (?SetBtnImageList@CCJControlBar@@QAEPAVCImageList@@PAV2@@Z)" imported
    LINK : warning LNK4049: locally defined symbol ""public: void __thiscall CCJControlBar::OpenCtrlBar(void)" (?OpenCtrlBar@CCJControlBar@@QAEXXZ)" imported
    MainFrm.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall CCJTabCtrlBar::~CCJTabCtrlBar(void)" (__imp_??1CCJTabCtrlBar@@UAE@XZ)
    MainFrm.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall CCJTabCtrlBar::CCJTabCtrlBar(void)" (__imp_??0CCJTabCtrlBar@@QAE@XZ)
    MainFrm.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall CCJTabCtrlBar::AddView(char const *,struct CRuntimeClass *,struct CCreateContext *)" (__imp_?AddView@CCJTabCtrlBar@@QAEHPBDPAUCRuntimeClass@@PAUCCr
    eateContext@@@Z)
    MainFrm.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall CCJControlBar::GetCloseStatus(void)" (__imp_?GetCloseStatus@CCJControlBar@@QAEHXZ)
    MainFrm.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall CCJControlBar::CloseCtrlBar(void)" (__imp_?CloseCtrlBar@CCJControlBar@@QAEXXZ)
    ./lib/Flow.exe : fatal error LNK1120: 5 unresolved externals
    Error executing link.exe.
      

  5.   

    原来DLL的lib是不是去掉了?
    注意C/C++编译设置中去掉_AFXDLL,
      

  6.   

    这是因为你的CJLib库没有放到连接选项里面去
      

  7.   

    原来的LIB已经被我覆盖掉了
    在LINK里面已经加入了CJ60Lib.lib,但是还是不行,仍然出上面的错误
      

  8.   

    Release版本中好象没有_AFXDLL这一项