Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Undefined Reference to code from my libraries
I know this has to do with the linking of the library with the compiler but I used x64 bit bash with Mingw64 to install and build the 64bit jsoncpp library using vpckg, I make sure to link the .lib file which is json.cpp inside the "installed" folder inside vpckg, i also include the include path, and then transfer the .dll of the library in the bin to my "release folder" within my program and link it with
win32: LIBS += -L$$PWD/../../Libraries/vcpkg/installed/x64-windows/lib/ -ljsoncpp LIBS += C:/Users/laner/Desktop/AlgoApplication/AlgoAppV02/AlgoAppV02/release/jsoncpp.dll INCLUDEPATH += $$PWD/../../Libraries/vcpkg/installed/x64-windows/include/json DEPENDPATH += $$PWD/../../Libraries/vcpkg/installed/x64-windows/include/json
but still i get undefined reference.. here are pictures of the files and error messages, any help would be appreciated.
@Laner107 There is no need to link twice to the same lib (especially not to the one in build/release folder).
The first LIBS should be enough.
Take a look at https://doc.qt.io/qt-5/qmake-variable-reference.html#libs
On Windows you link against *.lib not *.dll, so it should be:
win32: LIBS += -L$$PWD/../../Libraries/vcpkg/installed/x64-windows/lib/jsoncpp.lib INCLUDEPATH += $$PWD/../../Libraries/vcpkg/installed/x64-windows/include/json
@jsulm Thank you for the reply! I am now getting a bunch of undefined reference areas to my functions in my classes ie Json::value and Json::Reader? Any other fixes you have?
Json::value and Json::Reader
Are those from the jsoncpp lib?
Pablo J. Rogina last edited by
@Laner107 just in case, are you sure you want to use an external library to deal with JSON data?
There's already JSON support in Qt.
@jsulm I just want to verify this method of building libraries is compatiable with QT as libaries still confuse me, below is the steps i took.
1.) Run gitbash x64 mingw and clone and build vcpkg.
2.) Wtihin gitbash x64 mingw, install jsoncpp:x64-windows through vcpkg
3.) Include the jsoncpp.lib and json include path to qt.
So nothing else needs to be done for qt to essentially work?
AFAIK, vcpkg uses Visual Studio, are you sure these libraries where built using MinGW ?
As for Qt JSON support, @Pablo-J-Rogina already provided the link to the documentation of the module.
@SGaist So is there a way to install and build using gitbash without using vcpkg? I figured it was the most easiest.