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 code from my libraries
Forum Updated to NodeBB v4.3 + New Features

Undefined Reference to code from my libraries

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 965 Views 2 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.
  • L Offline
    L Offline
    Laner107
    wrote on 27 Apr 2020, 20:24 last edited by
    #1

    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.

    Pictures of files

    J P 2 Replies Last reply 28 Apr 2020, 05:02
    0
    • L Laner107
      27 Apr 2020, 20:24

      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.

      Pictures of files

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 28 Apr 2020, 05:02 last edited by
      #2

      @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
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 2 Replies Last reply 28 Apr 2020, 05:27
      0
      • J jsulm
        28 Apr 2020, 05:02

        @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
        
        L Offline
        L Offline
        Laner107
        wrote on 28 Apr 2020, 05:27 last edited by
        #3

        @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?

        J 1 Reply Last reply 28 Apr 2020, 06:11
        0
        • L Laner107
          28 Apr 2020, 05:27

          @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?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 28 Apr 2020, 06:11 last edited by
          #4

          @Laner107 said in Undefined Reference to code from my libraries:

          Json::value and Json::Reader

          Are those from the jsoncpp lib?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          L 1 Reply Last reply 28 Apr 2020, 15:57
          0
          • L Laner107
            27 Apr 2020, 20:24

            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.

            Pictures of files

            P Offline
            P Offline
            Pablo J. Rogina
            wrote on 28 Apr 2020, 14:19 last edited by
            #5

            @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.

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            1
            • J jsulm
              28 Apr 2020, 05:02

              @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
              
              L Offline
              L Offline
              Laner107
              wrote on 28 Apr 2020, 14:54 last edited by
              #6

              @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?

              1 Reply Last reply
              0
              • J jsulm
                28 Apr 2020, 06:11

                @Laner107 said in Undefined Reference to code from my libraries:

                Json::value and Json::Reader

                Are those from the jsoncpp lib?

                L Offline
                L Offline
                Laner107
                wrote on 28 Apr 2020, 15:57 last edited by
                #7

                @jsulm Yes they are in the library
                @Pablo-J-Rogina What is it called? And it can parse .json files?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 28 Apr 2020, 18:09 last edited by
                  #8

                  Hi,

                  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.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  L 1 Reply Last reply 28 Apr 2020, 19:25
                  1
                  • SGaistS SGaist
                    28 Apr 2020, 18:09

                    Hi,

                    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.

                    L Offline
                    L Offline
                    Laner107
                    wrote on 28 Apr 2020, 19:25 last edited by
                    #9

                    @SGaist So is there a way to install and build using gitbash without using vcpkg? I figured it was the most easiest.

                    1 Reply Last reply
                    0

                    1/9

                    27 Apr 2020, 20:24

                    • Login

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