请高手指点:
guilib(guitoolkit)是一个著名的UI库,提供静态库和dll调用,但是为什么它提供的例子中的静态库它的例子里无法使用(例子里原来用得是dll,我想改成lib)。它的头文件是这样设计的:#if defined _AFXDLL && !defined _GUILIB_STATIC_
#ifdef GUILIB_EXPORTS
   #define GUILIBDLLEXPORT  _declspec(dllexport)
#else
   #define GUILIBDLLEXPORT  _declspec(dllimport)
#endif
#else
#define GUILIBDLLEXPORT
#endif  
#ifndef _GUILIB_NOAUTOLIB#if defined _AFXDLL && !defined _GUILIB_STATIC_
// MFC shared DLL with GuiToolKit shared DLL
#ifdef _DEBUG
#ifdef _UNICODE
#pragma comment(lib,"GuiTk115ud.lib") 
#pragma message("Automatically linking with GuiTk115ud.dll")
#else
#pragma comment(lib,"GuiTk115d.lib") 
#pragma message("Automatically linking with GuiTk115d.dll")
#endif
#else
#ifdef _UNICODE
#pragma comment(lib,"GuiTk115u.lib") 
#pragma message("Automatically linking with GuiTk115u.dll") 
#else
#pragma comment(lib,"GuiTk115.lib") 
#pragma message("Automatically linking with GuiTk115.dll") 
#endif
#endif
#elif defined _GUILIB_STATIC_
// MFC shared DLL with GuiToolKit static library
#ifdef _DEBUG
#ifdef _UNICODE
#pragma comment(lib,"GuiTk115Staticuds.lib") 
#pragma message("Automatically linking with static GuiTk115Staticuds.lib") 
#else
#pragma comment(lib,"GuiTk115Staticds.lib") 
#pragma message("Automatically linking with static GuiTk115Staticds.lib") 
#endif
#else
#ifdef _UNICODE
#pragma comment(lib,"GuiTk115Staticus.lib") 
#pragma message("Automatically linking with static GuiTk115Staticus.lib") 
#else
#pragma comment(lib,"GuiTk115Statics.lib") 
#pragma message("Automatically linking with static GuiTk115Statics.lib") 
#endif
#endif
#else
// MFC static library with GuiToolKit static library
#ifdef _DEBUG
#ifdef _UNICODE
#pragma comment(lib,"GuiTk115Staticud.lib") 
#pragma message("Automatically linking with static GuiTk115Staticud.lib") 
#else
#pragma comment(lib,"GuiTk115Staticd.lib") 
#pragma message("Automatically linking with static GuiTk115Staticd.lib") 
#endif
#else
#ifdef _UNICODE
#pragma comment(lib,"GuiTk115Staticu.lib") 
#pragma message("Automatically linking with static GuiTk115Staticu.lib") 
#else
#pragma comment(lib,"GuiTk115Static.lib") 
#pragma message("Automatically linking with static GuiTk115Static.lib") 
#endif
#endif
#endif我已经解定义了_AFXDLL,定义了_staticlib, 把我的工程改为使用MFC静态库,但是还是出现链接错误。下载地址:
http://www.beyondata.com/

解决方案 »

  1.   

    对于CGuiAccess工程,在VC++ IDE的FileView tab把GuiLib删掉
    给工程加上_GUILIB_STATIC_宏定义
    修改apps-Sourcecode\GuiLib1.5\GuiLib\GuiLib.h
    #pragma comment(lib,"GuiTk115Static.lib") 
    // #pragma comment(lib,"GuiTk115Statics.lib") 
    注意没有GuiTk115Statics.lib这个文件,只有GuiTk115Static.lib
    上面的修改是针对release配置的。
      

  2.   

    我用得是VC .net 2003, 按照您的方法,出现以下错误:CGuiAccess error LNK2005: "int __stdcall _AfxGetDropDownWidth(void)" (?_AfxGetDropDownWidth@@YGHXZ) 已经在 GuiTk115Static.lib(GuiToolBarWnd.obj) 中定义
    CGuiAccess error LNK2005: "int _afxDropDownWidth" (?_afxDropDownWidth@@3HA) 已经在 GuiTk115Static.lib(GuiToolBarWnd.obj) 中定义
    CGuiAccess error LNK2005: "void __stdcall _AfxAdjustRectangle(class CRect &,class CPoint)" (?_AfxAdjustRectangle@@YGXAAVCRect@@VCPoint@@@Z) 已经在 GuiTk115Static.lib(GuiDockContext.obj) 中定义
    CGuiAccess error LNK2019: 无法解析的外部符号 "public: __thiscall CVisualStylesXP::~CVisualStylesXP(void)" (??1CVisualStylesXP@@QAE@XZ) ,该符号在函数 "public: static int __cdecl GuiDrawLayer::IsThemeXP(void)" (?IsThemeXP@GuiDrawLayer@@SAHXZ) 中被引用
    CGuiAccess error LNK2019: 无法解析的外部符号 "public: __thiscall CVisualStylesXP::~CVisualStylesXP(void)" (??1CVisualStylesXP@@QAE@XZ) ,该符号在函数 "public: static int __cdecl GuiDrawLayer::IsThemeXP(void)" (?IsThemeXP@GuiDrawLayer@@SAHXZ) 中被引用
    CGuiAccess error LNK2019: 无法解析的外部符号 "public: int __thiscall CVisualStylesXP::IsAppThemed(void)" (?IsAppThemed@CVisualStylesXP@@QAEHXZ) ,该符号在函数 "public: static int __cdecl GuiDrawLayer::IsThemeXP(void)" (?IsThemeXP@GuiDrawLayer@@SAHXZ) 中被引用
    CGuiAccess error LNK2019: 无法解析的外部符号 "public: int __thiscall CVisualStylesXP::IsAppThemed(void)" (?IsAppThemed@CVisualStylesXP@@QAEHXZ) ,该符号在函数 "public: static int __cdecl GuiDrawLayer::IsThemeXP(void)" (?IsThemeXP@GuiDrawLayer@@SAHXZ) 中被引用
    CGuiAccess error LNK2019: 无法解析的外部符号 "public: __thiscall CVisualStylesXP::CVisualStylesXP(void)" (??0CVisualStylesXP@@QAE@XZ) ,该符号在函数 "public: static int __cdecl GuiDrawLayer::IsThemeXP(void)" (?IsThemeXP@GuiDrawLayer@@SAHXZ) 中被引用
    CGuiAccess error LNK2019: 无法解析的外部符号 "public: __thiscall CVisualStylesXP::CVisualStylesXP(void)" (??0CVisualStylesXP@@QAE@XZ) ,该符号在函数 __ehhandler$?IsThemeXP@GuiDrawLayer@@SAHXZ 中被引用
    CGuiAccess fatal error LNK1120: 3 个无法解析的外部命令
      

  3.   

    add VisualStylesXP.cpp
    VisualStylesXP.h to GuiLibStatic projectmodify c:\Temp\apps-Sourcecode\GuiLib1.5\GuiLib\GuiOfficeBar.cpp
    extern void _AfxAdjustRectangle(CRect& rect, CPoint pt);
    //void  _AfxAdjustRectangle(CRect& rect, CPoint pt)
    //{
    // int nXOffset = (pt.x < rect.left) ? (pt.x - rect.left) :
    // (pt.x > rect.right) ? (pt.x - rect.right) : 0;
    // int nYOffset = (pt.y < rect.top) ? (pt.y - rect.top) :
    // (pt.y > rect.bottom) ? (pt.y - rect.bottom) : 0;
    // rect.OffsetRect(nXOffset, nYOffset);
    //}modify c:\Temp\apps-Sourcecode\GuiLib1.5\GuiLib\GuiDockContext.cpp
    static  void AFXAPI _AfxAdjustRectangle(CRect& rect, CPoint pt)
    {
    int nXOffset = (pt.x < rect.left) ? (pt.x - rect.left) :
    (pt.x > rect.right) ? (pt.x - rect.right) : 0;
    int nYOffset = (pt.y < rect.top) ? (pt.y - rect.top) :
    (pt.y > rect.bottom) ? (pt.y - rect.bottom) : 0;
    rect.OffsetRect(nXOffset, nYOffset);
    }modify C:\Temp\apps-Sourcecode\GuiLib1.5\GuiLib\GuiToolBarWnd.cppstatic int _afxDropDownWidth = -1;static int AFXAPI _AfxGetDropDownWidth()
    {
    // return cached version if already determined...
    if (_afxDropDownWidth != -1)
    return _afxDropDownWidth; // otherwise calculate it...
    HDC hDC = GetDC(NULL);
    ASSERT(hDC != NULL);
    HFONT hFont;
    if ((hFont = CreateFont(GetSystemMetrics(SM_CYMENUCHECK), 0, 0, 0,
    FW_NORMAL, 0, 0, 0, SYMBOL_CHARSET, 0, 0, 0, 0, _T("Marlett"))) != NULL)
    hFont = (HFONT)SelectObject(hDC, hFont);
    VERIFY(GetCharWidth(hDC, '6', '6', &_afxDropDownWidth));
    if (hFont != NULL)
    {
    SelectObject(hDC, hFont);
    DeleteObject(hFont);
    }
    ReleaseDC(NULL, hDC);
    ASSERT(_afxDropDownWidth != -1);
    return _afxDropDownWidth;
    }
    In solution tab, click on "Solution 'GuiToolKit' (12 projects)", open its property dialog
    Common Properties
    Project Dependencies
        Project : CCuiAccess
        Depends on:
        unselect GuiLib, select GuiLibStatic
      

  4.   

    高手啊,guilib里的BUG被您轻松搞定。PFPF。给分。另外收我短信。