Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't add external package in Qt
    primarykey
    data
    text
    <p>I'm newbie in C++ programming. I started from Qt 5.0.1. I need to use WebSockets from: <a href="https://code.google.com/p/tufao/" rel="nofollow">https://code.google.com/p/tufao/</a> but I don't have MinGW installation so I googled that I can create Qt library project, include these source files and build static library. So I did it:</p> <pre><code>QT += network QT -= gui TARGET = tufao TEMPLATE = lib CONFIG += staticlib INCLUDEPATH = src src/priv SOURCES += \ src/websocket.cpp \ src/url.cpp \ src/simplesessionstore.cpp \ src/sessionstore.cpp \ src/querystring.cpp \ src/httpserverresponse.cpp \ src/httpserverrequestrouter.cpp \ src/httpserverrequest.cpp \ src/httpserver.cpp \ src/httppluginserver.cpp \ src/httpfileserver.cpp \ src/headers.cpp \ src/abstractmessagesocket.cpp \ src/abstracthttpserverrequesthandler.cpp \ src/priv/tcpserverwrapper.cpp \ src/priv/rfc1123.cpp \ src/priv/rfc1036.cpp \ src/priv/reasonphrase.cpp \ src/priv/http_parser.c \ src/priv/asctime.cpp HEADERS += \ src/websocket.h \ src/url.h \ src/tufao_global.h \ src/simplesessionstore.h \ src/sessionstore.h \ src/sessionsettings.h \ src/session.h \ src/querystring.h \ src/ibytearray.h \ src/httpsserver.h \ src/httpserverresponse.h \ src/httpserverrequestrouter.h \ src/httpserverrequest.h \ src/httppluginserver.h \ src/httpfileserver.h \ src/headers.h \ src/abstractmessagesocket.h \ src/abstracthttpserverrequesthandlerfactory.h \ src/abstracthttpserverrequesthandler.h \ src/priv/websocket.h \ src/priv/url.h \ src/priv/tcpserverwrapper.h \ src/priv/simplesessionstore.h \ src/priv/sessionstore.h \ src/priv/rfc1123.h \ src/priv/rfc1036.h \ src/priv/reasonphrase.h \ src/priv/httpsserver.h \ src/priv/httpserverresponse.h \ src/priv/httpserverrequestrouter.h \ src/priv/httpserverrequest.h \ src/priv/httpserver.h \ src/priv/httppluginserver.h \ src/priv/httpfileserver.h \ src/priv/http_parser.h \ src/priv/cryptography.h \ src/priv/asctime.h unix:!symbian { maemo5 { target.path = /opt/usr/lib } else { target.path = /usr/lib } INSTALLS += target } </code></pre> <p>After build, I get <code>libtufao.a</code>. So next step is to test it. I created simple test project and added this library by clicking Add library -> external -> static. Open dialog can open only <code>.lib</code> files so I changed <code>libtufao.a</code> to <code>libtufao.lib</code>:</p> <pre><code>QT += core gui network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = sockettest TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h \ FORMS += mainwindow.ui win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../components/tufao-build-Desktop_Qt_5_0_1_MinGW_32bit-Release/release/ -llibtufao else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../components/tufao-build-Desktop_Qt_5_0_1_MinGW_32bit-Release/debug/ -llibtufao INCLUDEPATH += $$PWD/../../components/tufao/src DEPENDPATH += $$PWD/../../components/tufao/src win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../components/tufao-build-Desktop_Qt_5_0_1_MinGW_32bit-Release/release/libtufao.lib else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../components/tufao-build-Desktop_Qt_5_0_1_MinGW_32bit-Release/debug/libtufao.lib </code></pre> <p>But when I try to build this test project I get compiler error:</p> <blockquote> <p>undefined reference to `<em>imp</em>__ZN5Tufao9WebSocket13connectToHostERK12QHostAddresstRK10QByteArrayRKNS_7HeadersE' collect2.exe:-1:</p> <p>error: ld returned 1 exit status</p> </blockquote> <p>Can anyone help me?</p> <p>Regards</p> <p><strong>EDIT:</strong> Problem solved by adding all sources into my dest project and in <code>.pro</code> file I added <code>DEFINES += TUFAO_LIBRARY</code>. Now everything is compiling fine.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload