寫在前面:雖然qhttp-server編譯成功,已生成dll庫(kù),但在使用過程中,仍出現(xiàn)無(wú)法打開文件: “QtSslServer/QtSslServer”的問題,在多次解決無(wú)果后,決定放棄qhttp-server,選擇了QWebAPP,望知道的大佬可以幫忙解答一下,感謝~~
一、環(huán)境搭建
1、下載及解壓源文件
下載QtHttpServer源碼,網(wǎng)址:https://github.com/qt-labs/qthttpserver;
下載第三方依賴http-parser源碼,網(wǎng)址:https://github.com/nodejs/http-parser;
解壓兩文件,并復(fù)制http-parser-master文件夾下的文件到qthttpserver-master\src\3rdparty\http-parser目錄下?。
?2、QtCreator 打開qthttpserver-master目錄下的qthttpserver.pro
?
3、?編譯sslserver,會(huì)發(fā)現(xiàn)以下錯(cuò)誤,需要把<private/xxx.h>改為“xxx.h”,#include <QtSslServer/qsslserver.h>改為“xxx.h”,編譯成功后顯示生成Qt5SslServer.lib和Qt5SslServer.dll。
4、編譯httpserver,首先注釋加載sslserver,加載lib,lib路徑根據(jù)實(shí)際路徑加載。
問題一:
編譯出錯(cuò)時(shí),把<private/xxx.h>改為“xxx.h”,#include <QtHttpServer/qsslserver.h>改為“xxx.h”,編譯成功后顯示生成Qt5HttpServer.lib和Qt5HttpServer.dll。
問題二:
無(wú)法打開文件: “QtSslServer/QtSslServer”
解決方法:
問題三:
"compare" 不是 "QByteArray" 的成員
解決方法:
問題四:
"isEmpty" 不是 "QLatin1String" 的成員
解決方法:
問題五:
"xxx" 不是 "QFlags" 的成員
解決方法:刪除class
?編譯成功,如下:
參考鏈接?Qt開發(fā)的輕量級(jí)http服務(wù)器-QtHttpServer編譯_敲代碼的雪糕的博客-CSDN博客_qt http服務(wù)器
【最詳細(xì)】QtHttpServer編譯使用,親測(cè)可用_大陳1108的博客-CSDN博客_qhttpserver
二、使用QtHttpServer
1、將編譯好的QhttpServer文件拷貝到Qt對(duì)應(yīng)安裝目錄下
① 拷貝qthttpserver-master\build\bin下的全部文件放到Qt\5.9.9\msvc2017_64\bin;
② 拷貝qthttpserver-master\src\httpserver目錄下的頭文件到qthttpserver-master\build\include\QtHttpServer;
拷貝qthttpserver-master\src\sslserver目錄下的頭文件到qthttpserver-master\build\include\QtSslServer;
把qthttpserver-master\build\include下的QtHttpServer和QtSslServer文件夾拷貝到Qt\5.9.9\msvc2017_64\include;
③ 把下圖12個(gè)文件拷貝到Qt\5.9.9\msvc2017_64\lib;
④把qthttpserver-master\build\mkspecs\modules-inst下的文件拷貝到Qt\5.9.9\msvc2017_64\mkspecs\modules。?
2、pro加上sslserver和httpserver文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-474070.html
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-474070.html
到了這里,關(guān)于【Qt-4】QT基于qhttp-server搭建http服務(wù)器的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!