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. Qt Creator prompts the static library to have an unresolved external symbol but it's work well in VS
Forum Update on Monday, May 27th 2025

Qt Creator prompts the static library to have an unresolved external symbol but it's work well in VS

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 2.2k 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.
  • W Offline
    W Offline
    wzj1695224
    wrote on last edited by wzj1695224
    #1

    I has an project, like that:

    QZXing
      |----LibZXing     (Static Library)
      |----Demo         (Console Application)
    

    The LibZXing was built with none error and link success with same code in VS. When I try to build Demo, I got some unresolved externam symbol of LibZXing.

    LibZXing.pro

    QT -= core gui
    
    TEMPLATE = lib
    CONFIG += staticlib
    
    TARGET = libzxing
    
    DESTDIR = ../lib
    
    SOURCES += LibZXing.cpp \
        src/zxing/BarcodeFormat.cpp \
        ...
    
    HEADERS += LibZXing.h \
        src/zxing/BarcodeFormat.h \
        ...
    

    Demo.pro:

    QT -= core gui
    
    CONFIG += c++11 console
    CONFIG -= app_bundle
    
    TARGET = Demo
    TEMPLATE = app
    
    INCLUDEPATH += $$PWD/../LibZXing/src
    LIBS += -L../lib/ -llibzxing
    
    SOURCES += main.cpp
    
    ibzxing.lib(QRCodeReader.obj):-1: error: LNK2019: unresolved external symbol "public: __cdecl zxing::qrcode::Decoder::Decoder(void)" (??0Decoder@qrcode@zxing@@QEAA@XZ) referenced in function "public: __cdecl zxing::qrcode::QRCodeReader::QRCodeReader(void)" (??0QRCodeReader@qrcode@zxing@@QEAA@XZ)
    ...
    libzxing.lib(DataMatrixReader.obj):-1: error: LNK2019: unresolved external symbol "public: __cdecl zxing::datamatrix::Decoder::Decoder(void)" (??0Decoder@datamatrix@zxing@@QEAA@XZ) referenced in function "public: __cdecl zxing::datamatrix::DataMatrixReader::DataMatrixReader(void)" (??0DataMatrixReader@datamatrix@zxing@@QEAA@XZ)
    ...
    libzxing.lib(PDF417Reader.obj):-1: error: LNK2019: unresolved external symbol "public: class zxing::Ref<class zxing::DecoderResult> __cdecl zxing::pdf417::decoder::Decoder::decode(class zxing::Ref<class zxing::BitMatrix>,class zxing::DecodeHints const &)" (?decode@Decoder@decoder@pdf417@zxing@@QEAA?AV?$Ref@VDecoderResult@zxing@@@4@V?$Ref@VBitMatrix@zxing@@@4@AEBVDecodeHints@4@@Z) referenced in function "public: virtual class zxing::Ref<class zxing::Result> __cdecl zxing::pdf417::PDF417Reader::decode(class zxing::Ref<class zxing::BinaryBitmap>,class zxing::DecodeHints)" (?decode@PDF417Reader@pdf417@zxing@@UEAA?AV?$Ref@VResult@zxing@@@3@V?$Ref@VBinaryBitmap@zxing@@@3@VDecodeHints@3@@Z)
    ...
    qtmaind.lib(qtmain_win.obj):-1: error: LNK2019: unresolved external symbol main referenced in function WinMain
    

    Here is my project: Dropbox Share
    Thanks for your helping.

    jsulmJ 1 Reply Last reply
    0
    • W wzj1695224

      I has an project, like that:

      QZXing
        |----LibZXing     (Static Library)
        |----Demo         (Console Application)
      

      The LibZXing was built with none error and link success with same code in VS. When I try to build Demo, I got some unresolved externam symbol of LibZXing.

      LibZXing.pro

      QT -= core gui
      
      TEMPLATE = lib
      CONFIG += staticlib
      
      TARGET = libzxing
      
      DESTDIR = ../lib
      
      SOURCES += LibZXing.cpp \
          src/zxing/BarcodeFormat.cpp \
          ...
      
      HEADERS += LibZXing.h \
          src/zxing/BarcodeFormat.h \
          ...
      

      Demo.pro:

      QT -= core gui
      
      CONFIG += c++11 console
      CONFIG -= app_bundle
      
      TARGET = Demo
      TEMPLATE = app
      
      INCLUDEPATH += $$PWD/../LibZXing/src
      LIBS += -L../lib/ -llibzxing
      
      SOURCES += main.cpp
      
      ibzxing.lib(QRCodeReader.obj):-1: error: LNK2019: unresolved external symbol "public: __cdecl zxing::qrcode::Decoder::Decoder(void)" (??0Decoder@qrcode@zxing@@QEAA@XZ) referenced in function "public: __cdecl zxing::qrcode::QRCodeReader::QRCodeReader(void)" (??0QRCodeReader@qrcode@zxing@@QEAA@XZ)
      ...
      libzxing.lib(DataMatrixReader.obj):-1: error: LNK2019: unresolved external symbol "public: __cdecl zxing::datamatrix::Decoder::Decoder(void)" (??0Decoder@datamatrix@zxing@@QEAA@XZ) referenced in function "public: __cdecl zxing::datamatrix::DataMatrixReader::DataMatrixReader(void)" (??0DataMatrixReader@datamatrix@zxing@@QEAA@XZ)
      ...
      libzxing.lib(PDF417Reader.obj):-1: error: LNK2019: unresolved external symbol "public: class zxing::Ref<class zxing::DecoderResult> __cdecl zxing::pdf417::decoder::Decoder::decode(class zxing::Ref<class zxing::BitMatrix>,class zxing::DecodeHints const &)" (?decode@Decoder@decoder@pdf417@zxing@@QEAA?AV?$Ref@VDecoderResult@zxing@@@4@V?$Ref@VBitMatrix@zxing@@@4@AEBVDecodeHints@4@@Z) referenced in function "public: virtual class zxing::Ref<class zxing::Result> __cdecl zxing::pdf417::PDF417Reader::decode(class zxing::Ref<class zxing::BinaryBitmap>,class zxing::DecodeHints)" (?decode@PDF417Reader@pdf417@zxing@@UEAA?AV?$Ref@VResult@zxing@@@3@V?$Ref@VBinaryBitmap@zxing@@@3@VDecodeHints@3@@Z)
      ...
      qtmaind.lib(qtmain_win.obj):-1: error: LNK2019: unresolved external symbol main referenced in function WinMain
      

      Here is my project: Dropbox Share
      Thanks for your helping.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @wzj1695224 Remove lib from LIBS += -L../lib/ -llibzxing

      LIBS += -L../lib/ -lzxing
      

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

      W 1 Reply Last reply
      1
      • jsulmJ jsulm

        @wzj1695224 Remove lib from LIBS += -L../lib/ -llibzxing

        LIBS += -L../lib/ -lzxing
        
        W Offline
        W Offline
        wzj1695224
        wrote on last edited by wzj1695224
        #3

        @jsulm

         error: LNK1104: cannot open file 'zxing.lib'
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Where is libzxing.lib exactly located on your hard drive ?

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

          W 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Where is libzxing.lib exactly located on your hard drive ?

            W Offline
            W Offline
            wzj1695224
            wrote on last edited by
            #5

            @SGaist

            E:\Developments\Source\.build-qt-QZXing-Qt_5_7_0_MSVC_14_0\lib
            

            I had try to using absolute path, but it still have those problems.

            E:\Developments\Source
                |------.build-qt-QZXing-Qt_5_7_0_MSVC_14_0
                |          |-----------Demo (folder)
                |          |-----------lib (folder)
                |          |                |-------libzxing.lib
                |          |-----------LibZXing (folder)
                |
                |------QZXing
                |          |--------QZXing.pro
                |          |--------Demo (folder)
                |          |            |---------Demo.pro
                |          |           ...
                |          |--------LibZXing (folder)
                |          |            |---------LibZXing.pro
                |          |           ...
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Are you sure you are linking against a static version of libzxing.lib ?
              Because otherwise, it looks like the symbol are not properly tagged for export/import.

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

              W 1 Reply Last reply
              0
              • SGaistS SGaist

                Are you sure you are linking against a static version of libzxing.lib ?
                Because otherwise, it looks like the symbol are not properly tagged for export/import.

                W Offline
                W Offline
                wzj1695224
                wrote on last edited by wzj1695224
                #7

                @SGaist
                Merry Christmas!
                Yes, the libzxing.lib Qt Creator builds is same size as VS builds
                I has share my project.
                https://www.dropbox.com/s/d9o5zyirazbruty/QZXing.zip?dl=0

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Your main.cpp file is faulty, it doesn't contain a main function but a mains function.

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

                  W 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Your main.cpp file is faulty, it doesn't contain a main function but a mains function.

                    W Offline
                    W Offline
                    wzj1695224
                    wrote on last edited by wzj1695224
                    #9

                    @SGaist
                    Cause I want to test some function, so I wrote a new main function and renamed old one to mains. I forgot to change it back.
                    But this is not the key to my question, is it?
                    p.s. I had update the QZXing.zip

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      No indeed, it's not the key. However, having to first debug a project before being able to trigger the bug to check what is going wrong is not really nice.

                      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
                      0

                      • Login

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