Linking libCurl in QT gives a huge list of errors C++

亡梦爱人 提交于 2019-12-06 04:37:30

问题


I am trying to link libCurl in QT to a C++ program on Windows 7 x64, but when I try to link libcurldll.a, I get a huge list of errors. I have tried compiling a similar function with GCC g++ -LC:\MinGW\lib -lcurldll which compiles without errors. I am using the below code in QT and GCC.

void MainWindow::on_pushButton_2_clicked()
{
    CURL *curl;
    curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
    curl_easy_perform(curl);
    curl_easy_cleanup(curl);
}

QT gives me a huge list of errors that I have pasted here. Some of the key errors are tlsthrd.c:-1: error: undefined reference to 'EnterCriticalSection@4' I am using LIBS += -LC:\MinGW\lib -lcurldll in my .pro file to link the project to the curl library. Any idea as to why this is happening? Cheers.

Edit: After a deeper look, it appears as if libmingw32.a is having some issues providing references to functions used for multi-threading. Should I try and replace the library file? If so, why is GCC compiling correctly with the same library file but QT is not?


回答1:


Adding win32:LIBS += c:\MinGW\lib\libcurldll.a to the .pro file did the trick.




回答2:


Blarp. Don't use lib curl, Qt has QNetworkAccessManager already which elegantly handles requests and responses using thread-safe Qt signals. Everything you need is there already.



来源:https://stackoverflow.com/questions/8965631/linking-libcurl-in-qt-gives-a-huge-list-of-errors-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!