(转)将DuiLib编译成静态库
发布日期:2021-06-30 22:04:30
浏览次数:2
分类:技术文章
本文共 2543 字,大约阅读时间需要 8 分钟。
现在的工程要求是一个PE文件输出, 需要将DuiLib编译成静态库链接进主程序.
需要在Uilib.h中修改2处, 在主程序中还要加一处.
\3rd\DuiLib\UIlib.h
/// @todo 这是编译成静态库的设置/// 下面被注释掉的是原版DuiLibDll的设置#define UILIB_API // #if defined(UILIB_EXPORTS)// #if defined(_MSC_VER)// #define UILIB_API __declspec(dllexport)// #else// #define UILIB_API // #endif// #else// #if defined(_MSC_VER)// #define UILIB_API __declspec(dllimport)// #else// #define UILIB_API // #endif// #endif
Uilib.h末尾要包含一个库
/// @todo 编译静态库需要额外链接的库, 否则被链接的程序无法编译通过// #pragma comment(lib,"oledlg.lib")// #pragma comment(lib,"winmm.lib")#pragma comment(lib,"comctl32.lib")// #pragma comment(lib,"Riched20.lib")主程序中要引用atlbase.h 和 tchar.h
// testDuiLibStaticLib.cpp : Defines the entry point for the application.//#include "stdafx.h"#include "testDuiLibStaticLib.h"#include#pragma comment(lib, "DuiLib.lib")using namespace DuiLib;class CDuiFrameWnd : public CWindowWnd, public INotifyUI{public: virtual LPCTSTR GetWindowClassName() const { return _T("DUIMainFrame"); } virtual void Notify(TNotifyUI& msg) {} virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; if( uMsg == WM_CREATE ) { CControlUI *pWnd = new CButtonUI; pWnd->SetText(_T("Hello World")); // 设置文字 pWnd->SetBkColor(0xFF00FF00); // 设置背景色 m_PaintManager.Init(m_hWnd); m_PaintManager.AttachDialog(pWnd); return lRes; } if( m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes) ) { return lRes; } return __super::HandleMessage(uMsg, wParam, lParam); }protected: CPaintManagerUI m_PaintManager;};int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){ CPaintManagerUI::SetInstance(hInstance); CDuiFrameWnd duiFrame; duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE); duiFrame.ShowModal(); return 0;}
// stdafx.h : include file for standard system include files,// or project specific include files that are used frequently, but// are changed infrequently//#pragma once#include "targetver.h"#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers// Windows Header Files:#include主程序中只包含UI层, 然后开分别的的工程实现另外2个层 : 业务逻辑层 + 基础支撑层.#include #include // C RunTime Header Files#include #include #include #include // TODO: reference additional headers your program requires here
对于不同的程序,差别就是各层根据项目的区别有不同.
在程序不能包含Dll的情况下,使用主程序 + 多个静态库进行分层设计, 还是蛮优雅的.
转载地址:https://lostspeed.blog.csdn.net/article/details/19098213 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2024年04月26日 15时51分14秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
命令行神器 Click 快速上手
2021-07-04
『二十次幂』开发手记
2021-07-04
30分钟学会pyecharts数据可视化
2021-07-04
从一个骗子身上学到的
2021-07-04
关于Python爬虫,这里有一条高效的学习路径
2021-07-04
Python学习指南,看这篇清晰多了!
2019-05-01
Oracle裁员,3点建议
2019-05-01
「忙」只是借口
2019-05-01
如果只有1小时学Python,看这篇就够了
2019-05-01
命名难,难于上青天
2019-05-01
记一件小事
2019-05-01
一个牛逼的数据库操作命令行工具:mycli
2019-05-01
掌握 Python 爬虫的所有技巧,都在这里!
2019-05-01
史上最烂项目:苦撑12年,600多万行代码...
2019-05-01
关于进程与线程,史上最浅显易懂的一个简单解释
2019-05-01
别人用B站看弹幕,我用B站搞爬虫
2019-05-01
把 14 亿中国人都拉到一个微信群,在技术上能实现吗?
2019-05-01
这些代码神注释,请收下我的膝盖
2019-05-01
斯坦福后空翻机器人设计、代码全开源,成本降至3000美元,人人皆可DIY
2019-05-01
618|Python购书攻略
2019-05-01