博客
关于我
C++ Boost库初步使用 - 使用CFree
阅读量:110 次
发布时间:2019-02-26

本文共 3299 字,大约阅读时间需要 10 分钟。

首先下载并安装 Boost;

在CFree中编写代码如下;

#include 
#include "resource.h"#include
//#include "C://local//boost_1_70_0//boost//regex.hpp"using namespace std; LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); HINSTANCE hInst;TCHAR szClassName[] = TEXT("boostDemo");boost::regex exampleregex( "boost::regex" );boost::cmatch result; int WINAPIWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil){ HWND hwnd; MSG messages; WNDCLASSEX wincl; hInst = hThisInstance; wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof (WNDCLASSEX); wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = MAKEINTRESOURCE (IDC_BOOSTDEMO); wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); if (!RegisterClassEx (&wincl)) return 0; hwnd = CreateWindowEx ( 0, szClassName, TEXT("boostDemo"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 200, HWND_DESKTOP, NULL, hThisInstance, NULL ); ShowWindow (hwnd, nFunsterStil); while (GetMessage (&messages, NULL, 0, 0)) { TranslateMessage(&messages); DispatchMessage(&messages); } return messages.wParam;} LRESULT CALLBACKWindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ PAINTSTRUCT ps; HDC hdc; RECT rt; char szBuffer[100]; char *buf = "This is boost::regex example"; switch (message) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_boost: hdc=GetDC(hwnd); if( boost::regex_search( buf, result, exampleregex ) ) { //std::cout << result.str() << std::endl; wsprintf(szBuffer, "%s",result.str()); TextOut(hdc,20,20,szBuffer,lstrlen(szBuffer)); } break; case IDM_ABOUT: MessageBox (hwnd, TEXT ("boostDemo v1.0\nCopyright (C) 2020\n by bo"), TEXT ("boostDemo"), MB_OK | MB_ICONINFORMATION); break; case IDM_EXIT: DestroyWindow(hwnd); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } break; case WM_CREATE: break; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rt); EndPaint(hwnd, &ps); break; case WM_DESTROY: PostQuitMessage (0); break; default: return DefWindowProc (hwnd, message, wParam, lParam); } return 0;}

把boost目录拷贝到CFree的包含目录;

然后就能 #include <boost/regex.hpp>;<> 是表示系统路径;#include "",这是自己的路径;

此示例调用Boost的正则库;还需要相关的lib和dll文件;

照此文操作;

    

拷贝lib和dll到当前工程目录;

然后工程设置如下;

然后构建;出现错误;

    ld.exe: cannot find -lboost_regex-vc142-mt-x64-1_70

编译是没有问题;链接时候出错;

现在lib和dll有了;配置和  一样的;

为什么另一文会成功呢;看下CFree目录;当要使用自己的netapi32.lib和netapi32.dll时,CFree的库目录下有如下;

libnetapi32.a文件;目前要使用boost_regex-vc142-mt-x64-1_70.lib和dll;但是CFree的lib目录下没有 boost_regex-vc142-mt-x64-1_70.lib对应的.a文件;所以不能构建;

那么目前CFree 还不能支持Boost库;

转载地址:http://hhuy.baihongyu.com/

你可能感兴趣的文章
mysql 多个表关联查询查询时间长的问题
查看>>
mySQL 多个表求多个count
查看>>
mysql 多字段删除重复数据,保留最小id数据
查看>>
MySQL 多表联合查询:UNION 和 JOIN 分析
查看>>
MySQL 大数据量快速插入方法和语句优化
查看>>
mysql 如何给SQL添加索引
查看>>
mysql 字段区分大小写
查看>>
mysql 字段合并问题(group_concat)
查看>>
mysql 字段类型类型
查看>>
MySQL 字符串截取函数,字段截取,字符串截取
查看>>
MySQL 存储引擎
查看>>
mysql 存储过程 注入_mysql 视图 事务 存储过程 SQL注入
查看>>
MySQL 存储过程参数:in、out、inout
查看>>
mysql 存储过程每隔一段时间执行一次
查看>>
mysql 存在update不存在insert
查看>>
Mysql 学习总结(86)—— Mysql 的 JSON 数据类型正确使用姿势
查看>>
Mysql 学习总结(87)—— Mysql 执行计划(Explain)再总结
查看>>
Mysql 学习总结(88)—— Mysql 官方为什么不推荐用雪花 id 和 uuid 做 MySQL 主键
查看>>
Mysql 学习总结(89)—— Mysql 库表容量统计
查看>>
mysql 实现主从复制/主从同步
查看>>