Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Undefined reference to function availabel in external added library
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
using namespace Tins ;
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 functionZN4Tins10EthernetIID1Ev':
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.
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.
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.
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?
Yeah path is correct. I think it is problem of linker but I am not getting it.
I tried with double quotation also.