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. How to resolve undefined referece error when actually all function have defination and header ?
Forum Updated to NodeBB v4.3 + New Features

How to resolve undefined referece error when actually all function have defination and header ?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 214 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 embedded developer
    wrote on 17 Feb 2024, 13:47 last edited by
    #1

    Hi I have included the template = lib based static lib project's one c++ class file function into template = app based project.

    i don't know how to link this library and in what order i need to add sequence of building project.

    i have perfectly implemented the c++ class .

    When i build this project at that time it throws below error :

    /usr/bin/ld: Main.o: in function `main':
    /home/host/HOST/MainDir/Project/App/Main.cpp:17: undefined reference to `Engine::getInstance()'
    /usr/bin/ld: /home/host/HOST/MainDir/Project/App/Main.cpp:17: undefined reference to `Engine::setQmlEngine(QSharedPointer<QQmlApplicationEngine> const&)'
    collect2: error: ld returned 1 exit status
    make[1]: Leaving directory '/home/host/HOST/TWS_11_02_2024/15FEB2023/SubDirPOC/build-Project-Desktop_Qt_5_15_2_GCC_64bit-Debug/App'
    make[1]: *** [Makefile:246: App] Error 1
    make: *** [Makefile:73: sub-App-make_first] Error 2
    19:03:26: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project Project (kit: Desktop Qt 5.15.2 GCC 64bit)
    When executing step "Make"
    

    I have proper function for setQmlEngine method. but where i made mistake i want to know can any body help me how to resolve it.

    1 Reply Last reply
    0
    • S SGaist
      17 Feb 2024, 19:24

      Hi,

      How do you link to your library ?
      Are you sure things are done in the proper order ?

      Q Offline
      Q Offline
      Qt embedded developer
      wrote on 17 Feb 2024, 19:51 last edited by Qt embedded developer
      #3

      @SGaist This Part is learning for me. Because Yes i had not linked it.

      But when i have linked it

      Like

      LIBS += FULLPATH/libComponents.a

      It works fine.

      But what to do if we don't want to give full path and want to use another smart way so that i have to not write that full path.

      LIBS +=$$OUT_PWD/../Components/libComponents.a

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 17 Feb 2024, 19:24 last edited by
        #2

        Hi,

        How do you link to your library ?
        Are you sure things are done in the proper order ?

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

        Q 1 Reply Last reply 17 Feb 2024, 19:51
        1
        • S SGaist
          17 Feb 2024, 19:24

          Hi,

          How do you link to your library ?
          Are you sure things are done in the proper order ?

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on 17 Feb 2024, 19:51 last edited by Qt embedded developer
          #3

          @SGaist This Part is learning for me. Because Yes i had not linked it.

          But when i have linked it

          Like

          LIBS += FULLPATH/libComponents.a

          It works fine.

          But what to do if we don't want to give full path and want to use another smart way so that i have to not write that full path.

          LIBS +=$$OUT_PWD/../Components/libComponents.a

          1 Reply Last reply
          0
          • Q Qt embedded developer has marked this topic as solved on 17 Feb 2024, 21:00

          1/3

          17 Feb 2024, 13:47

          • Login

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