博客
关于我
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/

你可能感兴趣的文章
mysqldump备份时忽略某些表
查看>>
mysqldump实现数据备份及灾难恢复
查看>>
mysqldump数据库备份无法进行操作只能查询 --single-transaction
查看>>
mysqldump的一些用法
查看>>
mysqli
查看>>
MySQLIntegrityConstraintViolationException异常处理
查看>>
mysqlreport分析工具详解
查看>>
MySQLSyntaxErrorException: Unknown error 1146和SQLSyntaxErrorException: Unknown error 1146
查看>>
Mysql_Postgresql中_geometry数据操作_st_astext_GeomFromEWKT函数_在java中转换geometry的16进制数据---PostgreSQL工作笔记007
查看>>
mysql_real_connect 参数注意
查看>>
mysql_secure_installation初始化数据库报Access denied
查看>>
MySQL_西安11月销售昨日未上架的产品_20161212
查看>>
Mysql——深入浅出InnoDB底层原理
查看>>
MySQL“被动”性能优化汇总
查看>>
MySQL、HBase 和 Elasticsearch:特点与区别详解
查看>>
MySQL、Redis高频面试题汇总
查看>>
MYSQL、SQL Server、Oracle数据库排序空值null问题及其解决办法
查看>>
mysql一个字段为空时使用另一个字段排序
查看>>
MySQL一个表A中多个字段关联了表B的ID,如何关联查询?
查看>>
MYSQL一直显示正在启动
查看>>