Dlib库Window下Qt编译(用mingw)

参考文章如下:(俺还是很有版权意识滴,尊重原作者的劳动成果)

http://www.cnblogs.com/freegodly/p/4259040.html?utm\_source=tuicool&utm\_medium=referral

关于Dlib库的编译,网上都是依赖CMAKE,其实并不需要,用gcc或者mingw就可以的。

具体实践如下

1.下载最新Dlib库:

dlib-19.4.ziphttp://dlib.net/files/dlib-19.4.zip

2.解压缩(我的是E:\Dlib\dlib-19.4),你们随意

3.用Qt库新建工程

*.pro文件需要追加(重点)

    1).CONFIG += c++11(dlib是用C++11)

    2).SOURCES += E:/Dlib/dlib-19.4/dlib/all/source.cpp(为防止遗漏的头文件,就用这个)

    3).LIBS += -lwsock32  -lws2_32 -limm32  -luser32 -lgdi32 -lcomctl32 -lwinmm

        (这个就是依赖系统的库)

    4).INCLUDEPATH += E:/Dlib/dlib-19.4(指定头文件的路径)

        注,不知道是否为版本差异,参考那个文章没有追加(-lwinmm链接),会报下面这个错误

        E:\Dlib\dlib-19.4\dlib\misc_api\misc_api_kernel_1.cpp:98:

                error: undefined reference to `_imp__timeGetTime@0'

追踪代码后发现依赖window的DWORD WINAPI timeGetTime系统函数,百度一下就知道这个库依赖Winmm,

代码为参考文章的:

客户端:

1#include <iostream> 2#include <dlib/bridge.h> 3#include <dlib/type_safe_union.h> 4#include <dlib/timer.h> 5 6using namespace std; 7using namespace dlib; 8 9//管道 10dlib::pipe<string> out(4),in(4); 11 12//定时类 13class timer_task 14{ 15public: 16 void timer_send() 17 { 18 string msg("this client msg"); 19 out.enqueue(msg); 20 21 string re; 22 23 in.dequeue(re); 24 cout << "client receive :" << re << endl; 25 } 26}; 27 28int main() 29{ 30 bridge b1(connect_to_ip_and_port("127.0.0.1", 12345), \ 31 transmit(out), receive(in)); 32 33 timer_task task; 34 35 timer<timer_task> t(task, &timer_task::timer_send); 36 37 t.set_delay_time(1000); 38 39 t.start(); 40 41 dlib::sleep(10000000); 42 43 cout << "Hello World!" << endl; 44 return 0; 45}

服务器端:

1#include <iostream> 2 3#include<dlib/bridge.h> 4#include<dlib/type_safe_union.h> 5#include<dlib/timer.h> 6 7 8using namespace std; 9using namespace dlib; 10 11dlib::pipe<string> out(4),in(4); 12 13//定时类 14class timer_task 15{ 16public: 17 void timer_send() 18 { 19 string msg; 20 in.dequeue(msg); 21 cout << "server receive :" << msg << endl; 22 23 string value = "this is server send"; 24 25 out.enqueue(value); 26 } 27}; 28 29int main() 30{ 31 cout << "Hello World!" << endl; 32 33 bridge b1(listen_on_port(12345), transmit(out), receive(in)); 34 35 timer_task task; 36 37 timer<timer_task> t(task,&timer_task::timer_send); 38 39 t.set_delay_time(1000); 40 41 t.start(); 42 43 dlib::sleep(10000000); 44 return 0; 45}

运行结果如下:

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )