Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Undefined reference to function availabel in external added library

Undefined reference to function availabel in external added library

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qt_enthu
    wrote on last edited by
    #1

    I added external library by ADD LIBRARY method. When I am trying to use the functions available in library , errors are coming "undefined reference"
    My .pro file:-
    QT += core
    TARGET = libtnis
    SOURCES += main.cpp
    win32: LIBS += -L$$PWD/libtins-latest-win32/libtins-latest-win32/lib/ -ltins
    INCLUDEPATH += $$PWD/libtins-latest-win32/libtins-latest-win32/include
    DEPENDPATH += $$PWD/libtins-latest-win32/libtins-latest-win32/include
    win32:!win32-g++: PRE_TARGETDEPS += $$PWD/libtins-latest-win32/libtins-latest-win32/lib/tins.lib

    main.cpp

    #include<tins/tins.h>
    using namespace Tins ;
    int main()
    {
    EthernetII eth;
    return 0;
    }

    Following errors are coming while building the project………..
    C:\Qt\Tools\QtCreator\bin\build-lib_testing-Desktop_Qt_5_3_MinGW_32bit-Debug\debug\main.o:-1: In function `Z5qMainiPPc':

    C:\Qt\Tools\QtCreator\bin\lib_testing\main.cpp:12: error: undefined reference to Tins::EthernetII::EthernetII(Tins::HWAddress<6u, unsigned char> const&, Tins::HWAddress<6u, unsigned char> const&)' C:\Qt\Tools\QtCreator\bin\build-lib_testing-Desktop_Qt_5_3_MinGW_32bit-Debug\debug\main.o:-1: In function ZN4Tins10EthernetIID1Ev':
    C:\Qt\Tools\QtCreator\bin\lib_testing\libtins-latest-win32\libtins-latest-win32\include\tins\ethernetII.h:45: error: undefined reference to `vtable for Tins::EthernetII

    Is it problem of linker i.e . linker is unable to find definition of functions.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi, welcome to devnet.

      Have you tried to re-run qmake after adding the library (Build->Run qmake)? Changes in the .pro file are not picked up automatically.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qt_enthu
        wrote on last edited by
        #3

        Yeah , I tried it every time after making changes in .pro file.
        Same problem I am facing when I added winpcap library into my project.

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Are the paths correct? "libtins-latest-win32" is doubled in them.
          It also seems strange that you would have your project inside the QtCreator directory. Do you really keep it there?

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qt_enthu
            wrote on last edited by
            #5

            Yeah path is correct. I think it is problem of linker but I am not getting it.
            I tried with double quotation also.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved