在MSYS2下,执行
$pacman -S mingw32/mingw-w64-i686-librdkafka mingw64/mingw-w64-x86_64-librdkafka
即可获得二进制库、头文件和动态链接库。
文件路径实例,D:\msys64\mingw64下找文件即可:D:\msys64\mingw64\lib\librdkafka++.dll.a
在工程文件中创建文件夹thirdparty/librdkafka,配置如下:
├─bin │ libcrypto-1_1-x64.dll │ libgcc_s_seh-1.dll │ liblz4.dll │ librdkafka++.dll │ libssl-1_1-x64.dll │ libwinpthread-1.dll │ libzstd.dll │ zlib1.dll │ ├─include │ └─librdkafka │ rdkafkacpp.h │ rdkafka_mock.h │ └─lib librdkafka++.dll.a
工程文件配置如下
DEFINES += LIBRDKAFKA_STATICLIB
win32 {
LIBS += $$PWD/thirdparty/librdkafka/lib/librdkafka++.dll.a
LIBS += -lws2_32 -lsecur32 -lcrypt32
}
INCLUDEPATH+= $$PWD/thirdparty/librdkafka/include
头文件如下
#include <iostream> #include <string> #include <cstdlib> #include <cstdio> #include <csignal> #include <QDebug> #include <QObject> #include "librdkafka/rdkafkacpp.h"
最后使用MINGW_64编译器编译即可,缺库就去bin文件中找
(PS:32位的一直编译失败,不知道为什么,配置的也是32位的;)
标签:QT,lib,librdkafka,c++,dll,++.,64,include From: https://www.cnblogs.com/doctorlan/p/17928344.html