在obs工程中使用 如下头文件和函数之后,会提示link2019错误,是因为没有网络库。
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
QNetworkAccessManager qnam;
const QUrl aurl(url);
QNetworkRequest qnr(aurl);
qnr.setRawHeader("Content-Type", "application/json;charset=utf8");
QNetworkReply *reply = qnam.post(qnr, data.toLocal8Bit());
QEventLoop eventloop;
connect(reply, SIGNAL(finished()), &eventloop, SLOT(quit()));
eventloop.exec(QEventLoop::ExcludeUserInputEvents);
QTextCodec *codec = QTextCodec::codecForName("utf8");
QByteArray buf = reply->readAll();
添加qt5network.lib的方法还是要向cmake的 CMakeList.txt文件中加入一点脚本。
找到 target_link_libraries 在里面加入:Qt5::Network,在其前面加入:find_package(Qt5Network REQUIRED)。就可以了。
find_package(Qt5Network REQUIRED)
target_link_libraries(obs
libobs
Qt5::Widgets
Qt5::Network
obs-frontend-api
${FFMPEG_LIBRARIES}
${LIBCURL_LIBRARIES}
${obs_PLATFORM_LIBRARIES})
网友评论