安装配置qt_eventdispatcher_libevent

QT默认的是使用select模型的,这种轮询方式非常慢。在高并发连接,我们需要epoll才能发挥linux服务器的性能.
安装qt_eventdispatcher_libevent

下载安装包后,解压,找到src目录,用Qt打开pro工程,然后qmake, build。

编译完成后,在lib文件夹里增加三个文件:pkgconfig目录,libeventdispatcher_libevent.alibeventdispatcher_libevent.prl

在build文件夹里运行sudo make install。结果:
eventdispatcher_libevent.h拷贝到/usr/include
libeventdispatcher_libevent.a以及libeventdispatcher_libevent.prl拷贝到/usr/lib
eventdispatcher_libevent.pc拷贝到/usr/lib/pkgconfig

测试,新建工程,在pro文件里添加下面代码:

HEADERS += /path/to/eventdispatcher_libevent.h
LIBS    += -L/path/to/library -leventdispatcher_libevent    //.a文件

源文件:

#include <QCoreApplication>
#include <eventdispatcher_libevent.h>
#include <QThread>
int main(int argc, char *argv[])
{
    QCoreApplication::setEventDispatcher(new EventDispatcherLibEvent);
    QCoreApplication a(argc, argv);

    QThread* thr = new QThread;
    thr->setEventDispatcher(new EventDispatcherLibEvent);

//    auto *ser=new ConfigServer;
//    ser->startServer();
    return a.exec();
}

能正常运行就是安装成功

猜你喜欢

转载自blog.csdn.net/yao5hed/article/details/82186688