zl程序教程

您现在的位置是:首页 >  工具

当前栏目

在QT中添加zeromq DLL库

Qt 添加 dll zeromq
2023-09-11 14:22:48 时间

1)下载地址:http://zeromq.org/distro:microsoft-windows

2)按照说明。获取相应的版本,并安装。

3 ) 安装目录中,include文件集中下有两个文件夹:

zeromq_x64-windows和
czmq_x64-windows

3 ) 库文件,根据操作系统选择相应的文件。

    例):/zeromq_x64-windows/bin/libzmq-mt-4_3_3.lib

               /czmq_x64-windows/bin/libczmq.dll

讲上面两个库文件放入工程的构建目录

4)qtcreator 导入:

 然后在工程文件(*.pro)添加:

# czmq
INCLUDEPATH +=..\zeromq\zeromq_x64-windows\include
INCLUDEPATH +=..\zeromq\czmq_x64-windows\include
LIBS +=.\libczmq.dll
#LIBS +=.\libzmq-mt-4_3_3.dll

5)测试代码:

#include <QCoreApplication>
#include <czmq.h>
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    zsock_t *push = zsock_new_push ("tcp://127.0.0.1:5555");
    zsock_t *pull = zsock_new_pull ("tcp://127.0.0.1:5555");
    zstr_send (push, "Hello, World By zeromq");

    char *string = zstr_recv (pull);
    puts (string);
    zstr_free (&string);

    zsock_destroy (&pull);
    return a.exec();
}