Problems using anything contained in the QNetwork Libraries



  • Any time I try to use an object or function conatined in the QNetwork libraries, I get errors similar to the ones below

    Using this code I get the following error message

    @TestServer::TestServer(QObject *parent) :
    QObject(parent) , tcpServer(0), networkSession(0)
    {

    QNetworkConfigurationManager manager;
    
    if(manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
    
    }
    
    //manager.property()
    
    tcpServer = new QTcpServer(this);
    

    }@

    @debug/testserver.o: In function TestServer': C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:7: undefined reference toimp___ZN28QNetworkConfigurationManagerC1EP7QObject'
    C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop
    -_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:9: undefined reference to _imp___ZNK28QNetworkConfigurationManager12capabilitiesEv' C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:15: undefined reference toimp___ZN10QTcpServerC1EP7QObject'
    C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop
    -_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:15: undefined reference to _imp___ZN28QNetworkConfigurationManagerD1Ev' C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:15: undefined reference toimp___ZN28QNetworkConfigurationManagerD1Ev'
    C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop
    -_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:7: undefined reference to _imp___ZN28QNetworkConfigurationManagerC1EP7QObject' C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:9: undefined reference toimp___ZNK28QNetworkConfigurationManager12capabilitiesEv'
    C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop
    -_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:15: undefined reference to _imp___ZN10QTcpServerC1EP7QObject' C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:15: undefined reference toimp___ZN28QNetworkConfigurationManagerD1Ev'
    C:\Users\me\networktest-build-desktop-Qt_4_7_4_for_Desktop
    -_MinGW_4_4__Qt_SDK__Debug/../networktest/testserver.cpp:15: undefined reference to `_imp___ZN28QNetworkConfigurationManagerD1Ev'
    collect2: ld returned 1 exit status
    mingw32-make.exe[1]: *** [debug\networktest.exe] Error 1
    mingw32-make.exe: *** [debug] Error 2
    16:24:51: The process "E:\Qt\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project networktest (target: Desktop)
    When executing build step 'Make'@

    I have no idea what's causing the errors, and yes, "tcpServer" has already been declared



  • you need to add to your .pro file:

    @
    QT += network
    @



  • right..... I had it in my .pro as:

    @QT += core gui
    += network@

    instead of
    @QT += core gui
    QT += network@

    thanks for your help


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.