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. Linker error caused by Qt qjpeg4
Qt 6.11 is out! See what's new in the release blog

Linker error caused by Qt qjpeg4

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.2k 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.
  • P Offline
    P Offline
    pietrom
    wrote on last edited by
    #1

    I cannot link my project because of some issues with the qjpeg4 library.

    Its DLL is located here:

    @MY_PROJECT_ROOT/../Release/obj/imageformats/qjpeg4.dll@

    I get this linker error:

    @Linking CXX executable test.exe
    CMakeFiles\test.dir/objects.a(entrypoint.cpp.obj):entrypoint.cpp:(.text.startup+0x2692): undefined reference to `qt_plugin_instance_qjpeg()'
    collect2: ld returned 1 exit status
    @

    In the file containing main() I have: @Q_IMPORT_PLUGIN(qjpeg)@

    I tried adding these lines, with no improvement:

    @QApplication app(argc, argv);
    QString sDir = QCoreApplication::applicationDirPath();
    app.addLibraryPath(sDir + "/plugins");@

    The previous error should even not depend on the fact that the DLL has not been found, since it is still in the link phase...

    If in the file containing main() I remove Q_IMPORT_PLUGIN(qjpeg), the linker is successful, but the executable does absolutely nothing.

    The only Qt headers I include are <QApplication> and <QtPlugin>; adding <QtGui> has been useless.

    I am using cmake, and this is the token of my CMakeLists.txt file relative to Qt:

    @find_package(Qt4 REQUIRED)
    include(${QT_USE_FILE})
    add_definitions(${QT_DEFINITIONS})
    set(useQt_HEADERS )
    set(useQt_SOURCES entrypoint.cpp source.cpp)
    QT4_WRAP_CPP(useQt_HEADERS_MOC ${useQt_HEADERS})
    ...
    target_link_libraries(myProject ${QT_LIBRARIES} )
    @

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Please remove all the jpg-plugin related code from your source file and pro file.

      It's a plugin, and it will be automatically load by your application.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pietrom
        wrote on last edited by
        #3

        All I could remove from my code was:

        @QString sDir = QCoreApplication::applicationDirPath();
        app.addLibraryPath(sDir + "/plugins");@

        In CMakeLists.txt there is nothing related to the qjpg4 plugin, just general Qt stuff.
        In the file containing the main() function, I #include <QtPlugin>.
        Same behaviour.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dbzhang800
          wrote on last edited by
          #4

          Please remove the following code you added too.

          @
          Q_IMPORT_PLUGIN(qjpeg)
          @

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pietrom
            wrote on last edited by
            #5

            I removed
            @Q_IMPORT_PLUGIN(qjpeg)@

            Now it links.

            When I launch the executable (both from the command line and from the GUI), I get absolutely nothing. The main() function is not even entered. No error messages either.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              pietrom
              wrote on last edited by
              #6

              From this link, it seems to be a bug in Qt:

              "https://bugreports.qt-project.org/browse/QTBUG-24177":https://bugreports.qt-project.org/browse/QTBUG-24177

              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