Linker error caused by Qt qjpeg4
-
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} )
@ -
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.
-
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. -
Please remove the following code you added too.
@
Q_IMPORT_PLUGIN(qjpeg)
@ -
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.
-
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