Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Getting two "LNK2019: unresolved external symbol" using libqrencode

    General and Desktop
    libqrencode qrencode lnk2019 unresolved exte qt5.5
    2
    5
    3313
    Loading More Posts
    • 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.
    • Emile P
      Emile P last edited by

      I made a program on Qt Creator on OSX, but I'm having some issues opening the project on Windows to compile it over there. My program uses the qrencode library (http://fukuchi.org/works/qrencode/), which worked flawlessly on OSX, but I'm having trouble getting it to work here on Windows.
      After having a lot of trouble actually installing the library and getting my Qt project to find it, I'm now getting the two LNK2019 errors below:

      mainwindow.obj:-1: error: LNK2019: unresolved external symbol _QRcode_free referenced in function "private: void __thiscall MainWindow::updateQRImage(class QString)" (?updateQRImage@MainWindow@@AAEXVQString@@@Z)

      mainwindow.obj:-1: error: LNK2019: unresolved external symbol _QRcode_encodeString referenced in function "private: void __thiscall MainWindow::updateQRImage(class QString)" (?updateQRImage@MainWindow@@AAEXVQString@@@Z)

      Here is the code that uses the library, as well as the .pro file:

      MainWindow::updateQRImage
      @
      void MainWindow::updateQRImage(QString link)
      {
      QRcode *qr = QRcode_encodeString(link.toStdString().c_str(), 1, QR_ECLEVEL_L, QR_MODE_8, 1);
      QPixmap *QRpixmap = new QPixmap(920, 920);
      QPainter painter(QRpixmap);

      if(0 != qr) {
      
          QColor fg("black");
          QColor bg("white");
          painter.setBrush(bg);
          painter.setPen(Qt::NoPen);
          painter.drawRect(0, 0, QRpixmap->width(), QRpixmap->height());
          painter.setBrush(fg);
          const int s = qr->width > 0 ? qr->width : 1;
          const double w = QRpixmap->width();
          const double h = QRpixmap->height();
          const double aspect = w / h;
          const double scale = ((aspect > 1.0) ? h : w) / s;
          for (int y=0; y<s; y++) {
              const int yy = y * s;
              for (int x=0; x<s; x++) {
                  const int xx = yy + x;
                  const unsigned char b = qr->data[xx];
                  if(b &0x01){
                      const double rx1=x*scale, ry1=y*scale;
                      QRectF r(rx1, ry1, scale, scale);
                      painter.drawRects(&r,1);
                  }
              }
          }
          QRcode_free(qr);
      
      }
      else{
          QColor error("red");
          painter.setBrush(error);
          painter.drawRect(0,0,width(),height());
      }
      qr = 0;
      painter.end();
      
      QPixmap *borderedQR = new QPixmap(1000, 1000);
      QPainter borderPainter(borderedQR);
      
      borderPainter.setBrush(QColor("white"));
      borderPainter.setPen(Qt::NoPen);
      borderPainter.drawRect(0, 0, borderedQR->width(), borderedQR->height());
      borderPainter.drawPixmap((borderedQR->width() - QRpixmap->width()) / 2, (borderedQR->height() - QRpixmap->height()) / 2, *QRpixmap);
      borderPainter.end();
      delete QRpixmap;
      
      this->full_QR_pixmap->swap(*borderedQR);
      delete borderedQR;
      
      
      setImageFromPixmap(*this->full_QR_pixmap, ui->lblQR);
      

      }
      @

      .pro file
      @
      #-------------------------------------------------

      Project created by QtCreator 2015-06-30T14:13:00

      #-------------------------------------------------

      QT += core gui

      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

      TARGET = PlaquesMetalliques
      TEMPLATE = app

      SOURCES += main.cpp
      mainwindow.cpp
      croppingwindow.cpp
      gui_functions.cpp
      aspectratio.cpp
      misc_functions.cpp
      carddata.cpp
      catalogdialog.cpp

      HEADERS += mainwindow.h
      croppingwindow.h
      gui_functions.h
      aspectratio.h
      misc_functions.h
      carddata.h
      catalogdialog.h

      FORMS += mainwindow.ui
      croppingwindow.ui
      catalogdialog.ui

      RESOURCES +=
      defaultressource.qrc

      DISTFILES +=
      pensees.txt

      INCLUDEPATH += $$PWD/include
      DEPENDPATH += $$PWD/include

      PRE_TARGETDEPS += $$PWD/lib/libqrencode.a

      LIBS += $$PWD/lib/libqrencode.a

      @CONFIG += debug_and_release@
      @

      Here is also the include line for the qrencode library, in mainwindow.h
      @
      #include <qrencode.h>
      @

      Does anyone know how I could go about fixing this? I've been trying to get the library to work on Windows for over a week now... :|

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Did you compile libqrencode with the same compiler you are using for your Qt project ? And for the same architecture ?

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

        Emile P 1 Reply Last reply Reply Quote 0
        • Emile P
          Emile P @SGaist last edited by

          @SGaist
          I built the libqrencode library using cygwin, with the same commands I had used on OSX (the ones that are recommended on the library's webpage).
          I seem to be using different kits than on my Qt Creator on OSX though, which is most likely the source of the issue. I am using Desktop Qt 5.4.2 clang 64bit on OSX, and Desktop 5.5.0 MSVC2010 32bit on Windows. How would I go about fixing this? I don't know anything about adding new kits, and I doubt (after a quick google search) that clang can be used on Windows. :/

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            On Windows, you can't mix compilers not even different version of Visual Studio, they are not compatible one with the other. So you have to build libqrencode with Visual Studio 2010

            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 Reply Quote 0
            • Emile P
              Emile P last edited by

              I will try to build it with Visual Studio 2010 tomorrow, and see if that helps!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post