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. LNK2019: unresolved external symbol issue happens when calling a function from third party static library
Forum Update on Monday, May 27th 2025

LNK2019: unresolved external symbol issue happens when calling a function from third party static library

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 5 Posters 8.7k Views
  • 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.
  • U Offline
    U Offline
    Uddo_ud
    wrote on 19 Dec 2018, 11:00 last edited by
    #1

    Hi all,

    I'm a newbie to QT. I have imported the third party static libraries to my project successfully. When I try to call a function in the main.cpp, it gives LNK2019: unresolved external symbol... issue. I'm compiling my project with the MSVC2017 32bit compiler. If the main function is empty, project builds successfully.

    I went through a lot of forums. I would like to know the exact reason for this. I tried every possible solutions that worked for others. But yet not able to find a solution for my issue.

    Thanks in advance!

    A 1 Reply Last reply 19 Dec 2018, 12:01
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 19 Dec 2018, 11:15 last edited by
      #2

      unresolved external symbol

      This clearly indicates that

      1. Either your library is not found in the directory or
      2. Method which you are trying to access is not there in library
      3. Library is compiled using different compiler and u r using MSCVC
      4. Library is 64 bit and your project 32 bit.

      Just check all this.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      U 1 Reply Last reply 20 Dec 2018, 03:22
      4
      • U Uddo_ud
        19 Dec 2018, 11:00

        Hi all,

        I'm a newbie to QT. I have imported the third party static libraries to my project successfully. When I try to call a function in the main.cpp, it gives LNK2019: unresolved external symbol... issue. I'm compiling my project with the MSVC2017 32bit compiler. If the main function is empty, project builds successfully.

        I went through a lot of forums. I would like to know the exact reason for this. I tried every possible solutions that worked for others. But yet not able to find a solution for my issue.

        Thanks in advance!

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 19 Dec 2018, 12:01 last edited by
        #3

        @Uddo_ud

        I want to add something to @dheerendra's list.

        It might be silly question, but are you actually linking against the external library?

        Qt has to stay free or it will die.

        U 1 Reply Last reply 20 Dec 2018, 03:52
        2
        • D dheerendra
          19 Dec 2018, 11:15

          unresolved external symbol

          This clearly indicates that

          1. Either your library is not found in the directory or
          2. Method which you are trying to access is not there in library
          3. Library is compiled using different compiler and u r using MSCVC
          4. Library is 64 bit and your project 32 bit.

          Just check all this.

          U Offline
          U Offline
          Uddo_ud
          wrote on 20 Dec 2018, 03:22 last edited by
          #4

          @dheerendra

          Point 1 and 4 you have mentioned are already checked. I will check the others as well.

          1 Reply Last reply
          0
          • A aha_1980
            19 Dec 2018, 12:01

            @Uddo_ud

            I want to add something to @dheerendra's list.

            It might be silly question, but are you actually linking against the external library?

            U Offline
            U Offline
            Uddo_ud
            wrote on 20 Dec 2018, 03:52 last edited by
            #5

            @aha_1980

            I didn't get your question. Can you explain it further

            J 1 Reply Last reply 20 Dec 2018, 05:25
            0
            • U Uddo_ud
              20 Dec 2018, 03:52

              @aha_1980

              I didn't get your question. Can you explain it further

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 20 Dec 2018, 05:25 last edited by
              #6

              @Uddo_ud said in LNK2019: unresolved external symbol issue happens when calling a function from third party static library:

              I didn't get your question. Can you explain it further

              Is your app linked against that library? Did you add the lib to your pro file (you can show your pro file so we can check)?

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

              U 1 Reply Last reply 20 Dec 2018, 05:53
              0
              • J jsulm
                20 Dec 2018, 05:25

                @Uddo_ud said in LNK2019: unresolved external symbol issue happens when calling a function from third party static library:

                I didn't get your question. Can you explain it further

                Is your app linked against that library? Did you add the lib to your pro file (you can show your pro file so we can check)?

                U Offline
                U Offline
                Uddo_ud
                wrote on 20 Dec 2018, 05:53 last edited by
                #7

                @jsulm

                Yes I added the libs to my .pro file.

                win32: LIBS += -L$$PWD/engine/lib/PVR3_PC_EMU/ -llibanimation-vc90-mt-s

                INCLUDEPATH += $$PWD/engine/lib/PVR3_PC_EMU
                DEPENDPATH += $$PWD/engine/lib/PVR3_PC_EMU

                win32:!win32-g++: PRE_TARGETDEPS += $$PWD/engine/lib/PVR3_PC_EMU/libanimation-vc90-mt-s.lib

                I want to use another engine libraries to do the task and QT act as a wrapper in that case. However I couldn't even call at least one function successfully.

                Is there any solid way to include third party static libraries?

                J 1 Reply Last reply 20 Dec 2018, 05:56
                0
                • U Uddo_ud
                  20 Dec 2018, 05:53

                  @jsulm

                  Yes I added the libs to my .pro file.

                  win32: LIBS += -L$$PWD/engine/lib/PVR3_PC_EMU/ -llibanimation-vc90-mt-s

                  INCLUDEPATH += $$PWD/engine/lib/PVR3_PC_EMU
                  DEPENDPATH += $$PWD/engine/lib/PVR3_PC_EMU

                  win32:!win32-g++: PRE_TARGETDEPS += $$PWD/engine/lib/PVR3_PC_EMU/libanimation-vc90-mt-s.lib

                  I want to use another engine libraries to do the task and QT act as a wrapper in that case. However I couldn't even call at least one function successfully.

                  Is there any solid way to include third party static libraries?

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 20 Dec 2018, 05:56 last edited by
                  #8

                  @Uddo_ud said in LNK2019: unresolved external symbol issue happens when calling a function from third party static library:

                  -llibanimation-vc90-mt-s

                  You should remove the "lib" prefix:

                  win32: LIBS += -L$$PWD/engine/lib/PVR3_PC_EMU/ -lanimation-vc90-mt-s
                  

                  To add a static lib do

                  LIBS += PATH_TO_LIB_DIR/libLIBNAME.a
                  

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

                  U 1 Reply Last reply 20 Dec 2018, 06:34
                  2
                  • J jsulm
                    20 Dec 2018, 05:56

                    @Uddo_ud said in LNK2019: unresolved external symbol issue happens when calling a function from third party static library:

                    -llibanimation-vc90-mt-s

                    You should remove the "lib" prefix:

                    win32: LIBS += -L$$PWD/engine/lib/PVR3_PC_EMU/ -lanimation-vc90-mt-s
                    

                    To add a static lib do

                    LIBS += PATH_TO_LIB_DIR/libLIBNAME.a
                    
                    U Offline
                    U Offline
                    Uddo_ud
                    wrote on 20 Dec 2018, 06:34 last edited by
                    #9

                    @jsulm

                    First of all "libanimation-vc90-mt-s.lib" is the name of the library file and "lib" you have focused is not a prefix.

                    Secondly, there is no "libanimation-vc90-mt-s.a" file in my libs folder. I tried to add as you said and ended up with "file not found" error.

                    J A 2 Replies Last reply 20 Dec 2018, 06:54
                    0
                    • U Uddo_ud
                      20 Dec 2018, 06:34

                      @jsulm

                      First of all "libanimation-vc90-mt-s.lib" is the name of the library file and "lib" you have focused is not a prefix.

                      Secondly, there is no "libanimation-vc90-mt-s.a" file in my libs folder. I tried to add as you said and ended up with "file not found" error.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 20 Dec 2018, 06:54 last edited by
                      #10

                      @Uddo_ud What is the whole file name of libanimation-vc90-mt-s.lib?
                      When adding libs with -l the lib prefix must be removed.

                      Static lib was just an example, on Windows it may be different (.lib maybe?).

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

                      U 1 Reply Last reply 20 Dec 2018, 07:59
                      0
                      • U Uddo_ud
                        20 Dec 2018, 06:34

                        @jsulm

                        First of all "libanimation-vc90-mt-s.lib" is the name of the library file and "lib" you have focused is not a prefix.

                        Secondly, there is no "libanimation-vc90-mt-s.a" file in my libs folder. I tried to add as you said and ended up with "file not found" error.

                        A Offline
                        A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on 20 Dec 2018, 07:13 last edited by
                        #11

                        @Uddo_ud said in LNK2019: unresolved external symbol issue happens when calling a function from third party static library:

                        "vc90" looks like a very old version of MS C++ compiler. Is that still compatible with the current version?

                        Qt has to stay free or it will die.

                        U 2 Replies Last reply 20 Dec 2018, 09:48
                        0
                        • J jsulm
                          20 Dec 2018, 06:54

                          @Uddo_ud What is the whole file name of libanimation-vc90-mt-s.lib?
                          When adding libs with -l the lib prefix must be removed.

                          Static lib was just an example, on Windows it may be different (.lib maybe?).

                          U Offline
                          U Offline
                          Uddo_ud
                          wrote on 20 Dec 2018, 07:59 last edited by
                          #12

                          @jsulm

                          @Uddo_ud What is the whole file name of libanimation-vc90-mt-s.lib?

                          0_1545289607812_ed45e61f-71e5-4c13-9c85-c1413aa46761-image.png

                          Static lib was just an example, on Windows it may be different (.lib maybe?).

                          Yes I tried adding .lib also. But Linker issue yet happens.

                          1 Reply Last reply
                          0
                          • A aha_1980
                            20 Dec 2018, 07:13

                            @Uddo_ud said in LNK2019: unresolved external symbol issue happens when calling a function from third party static library:

                            "vc90" looks like a very old version of MS C++ compiler. Is that still compatible with the current version?

                            U Offline
                            U Offline
                            Uddo_ud
                            wrote on 20 Dec 2018, 09:48 last edited by
                            #13

                            @aha_1980

                            Yes this might be the problem. Earlier I thought it was compatible and then I tried this with another working sample project. Now I need to check with the actual project. Thank you very much. I will check it and let you know the progress.

                            1 Reply Last reply
                            1
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 20 Dec 2018, 22:00 last edited by
                              #14

                              Hi,

                              Visual Studio compilers are not compatible one with the other except for VS2017 which is backward compatible with VS2015 There for you can't mix and match libraries.

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

                              1 Reply Last reply
                              3
                              • A aha_1980
                                20 Dec 2018, 07:13

                                @Uddo_ud said in LNK2019: unresolved external symbol issue happens when calling a function from third party static library:

                                "vc90" looks like a very old version of MS C++ compiler. Is that still compatible with the current version?

                                U Offline
                                U Offline
                                Uddo_ud
                                wrote on 21 Dec 2018, 07:42 last edited by
                                #15

                                @aha_1980

                                "vc90" looks like a very old version of MS C++ compiler. Is that still compatible with the current version?

                                I built the libraries in VS2015 and included those to Qt project and compile using MSVC2017 32bit and MSVC2015 32bit both. Most of the linker issues were solved but some are remain still.

                                A 1 Reply Last reply 21 Dec 2018, 08:18
                                0
                                • U Uddo_ud
                                  21 Dec 2018, 07:42

                                  @aha_1980

                                  "vc90" looks like a very old version of MS C++ compiler. Is that still compatible with the current version?

                                  I built the libraries in VS2015 and included those to Qt project and compile using MSVC2017 32bit and MSVC2015 32bit both. Most of the linker issues were solved but some are remain still.

                                  A Offline
                                  A Offline
                                  aha_1980
                                  Lifetime Qt Champion
                                  wrote on 21 Dec 2018, 08:18 last edited by
                                  #16

                                  @Uddo_ud

                                  Most of the linker issues were solved but some are remain still.

                                  are they related to this library or something else?

                                  Qt has to stay free or it will die.

                                  U 1 Reply Last reply 21 Dec 2018, 09:00
                                  0
                                  • A aha_1980
                                    21 Dec 2018, 08:18

                                    @Uddo_ud

                                    Most of the linker issues were solved but some are remain still.

                                    are they related to this library or something else?

                                    U Offline
                                    U Offline
                                    Uddo_ud
                                    wrote on 21 Dec 2018, 09:00 last edited by
                                    #17

                                    @aha_1980

                                    To refer I previously sent only one library (libanimation-vc90-mt-s.lib). There are 5 libraries. The problem with the libanimation-vc90-mt-s.lib is solved now. Now the problem is with the libloader-vc90-mt-s.lib. All the included libraries are now build in VS2015.

                                    U 1 Reply Last reply 21 Dec 2018, 09:43
                                    0
                                    • U Uddo_ud
                                      21 Dec 2018, 09:00

                                      @aha_1980

                                      To refer I previously sent only one library (libanimation-vc90-mt-s.lib). There are 5 libraries. The problem with the libanimation-vc90-mt-s.lib is solved now. Now the problem is with the libloader-vc90-mt-s.lib. All the included libraries are now build in VS2015.

                                      U Offline
                                      U Offline
                                      Uddo_ud
                                      wrote on 21 Dec 2018, 09:43 last edited by
                                      #18

                                      Additionally,

                                      This is an existing VS project I'm trying to do using QT. I built the VS solution in VS2015 and VS2017. Both work fine with the vc90 libraries. Issues occur when comes to QT.

                                      Is that a problem with QT creator?

                                      A 1 Reply Last reply 21 Dec 2018, 09:50
                                      0
                                      • U Uddo_ud
                                        21 Dec 2018, 09:43

                                        Additionally,

                                        This is an existing VS project I'm trying to do using QT. I built the VS solution in VS2015 and VS2017. Both work fine with the vc90 libraries. Issues occur when comes to QT.

                                        Is that a problem with QT creator?

                                        A Offline
                                        A Offline
                                        aha_1980
                                        Lifetime Qt Champion
                                        wrote on 21 Dec 2018, 09:50 last edited by aha_1980
                                        #19

                                        @Uddo_ud

                                        Is that a problem with QT creator?

                                        Well, Creator calls qmake to create the Makefiles and afterwards nmake/jom to build the project. The compiler and linker are exactly the same as in VS itself.

                                        The only thing I can imagine is that some environment paths are not correctly so the linker pulls in something different.

                                        What's a bit of a problem is, the linker command line does not contain the objects list, they are rather in a temporary file. Debugging this is painful...

                                        Edit: Can you please give a concrete example of this linker error? Is it for pure C or C++ symbols?

                                        Qt has to stay free or it will die.

                                        U 1 Reply Last reply 21 Dec 2018, 11:15
                                        0
                                        • A aha_1980
                                          21 Dec 2018, 09:50

                                          @Uddo_ud

                                          Is that a problem with QT creator?

                                          Well, Creator calls qmake to create the Makefiles and afterwards nmake/jom to build the project. The compiler and linker are exactly the same as in VS itself.

                                          The only thing I can imagine is that some environment paths are not correctly so the linker pulls in something different.

                                          What's a bit of a problem is, the linker command line does not contain the objects list, they are rather in a temporary file. Debugging this is painful...

                                          Edit: Can you please give a concrete example of this linker error? Is it for pure C or C++ symbols?

                                          U Offline
                                          U Offline
                                          Uddo_ud
                                          wrote on 21 Dec 2018, 11:15 last edited by Uddo_ud
                                          #20

                                          @aha_1980

                                          Here is the error log

                                          0_1545390111043_Screenshot (19).png

                                          Is it for pure C or C++ symbols?

                                          I didn't get this.

                                          The only thing I can imagine is that some environment paths are not correctly so the linker pulls in something different.

                                          Is this means the build environment settings in the QT project? I will check it.

                                          In the project we have included <windows.h>. Path to the windows SDK in the QT build environment might be the problem?

                                          U 1 Reply Last reply 28 Dec 2018, 03:48
                                          0

                                          1/21

                                          19 Dec 2018, 11:00

                                          • Login

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