This happens on an EL7 box with Qt5 and mingw from EPEL: Linking CXX executable be.contacts.exe /usr/bin/cmake -E cmake_link_script CMakeFiles/be.contacts.dir/link.txt --verbose=1 /usr/bin/cmake -E remove -f CMakeFiles/be.contacts.dir/objects.a /usr/bin/i686-w64-mingw32-ar cr CMakeFiles/be.contacts.dir/objects.a @CMakeFiles/be.contacts.dir/objects1.rsp /usr/bin/i686-w64-mingw32-g++ -Wall -Wsign-compare -O2 -std=c++11 -O3 -DNDEBUG -mwindows -Wl,--whole-archive CMakeFiles/be.contacts.dir/objects.a -Wl,--no-whole-archive -o be.contacts.exe -Wl,--out-implib,libbe.contacts.dll.a -Wl,--major-image-version,0,--minor-image-version,0 libtrojita_plugins.dll.a trojita_plugin_AbookAddressbookPlugin.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Widgets.dll.a libtrojita_plugins.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Gui.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Core.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libqt5main.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 CMakeFiles/be.contacts.dir/objects.a(main.cpp.obj):main.cpp:(.text.startup+0x4): undefined reference to `qt_static_plugin_trojita_plugin_AbookAddressbookPlugin()' cmake is invoked as `cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_RPATH:BOOL=ON -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake -DWITH_TESTS=OFF -DQT_QMAKE_EXECUTABLE=/bin/i686-w64-mingw32-qmake-qt5 -DWITH_NSIS=OFF -DOPENSSL_DLL_LIBRARIES='libssl-10.dll;libcrypto-10.dll' ..`. If I pass -DWITH_ABOOKADDRESSBOOK_PLUGIN=ON -DWITH_CLEARTEXT_PLUGIN=ON , then stuff builds, but I apparently don't know where to put these plugins, so I get an immediate crash in be.contacts.exe, and no plugins in trojita.exe. Tried using cwd as well as ./plugins/, as suggested in the docs.
Do you have "-DQT_STATICPLUGIN" on building src/Plugins/AbookAddressbook/main.cpp? (The next question would be whether it makes its path down)
> Do you have "-DQT_STATICPLUGIN" on building > src/Plugins/AbookAddressbook/main.cpp? I think that yeah: [turbo-hipster@ci-el7-big-1 build]$ rm trojita_plugin_AbookAddressbookPlugin.a CMakeFiles/be.contacts.dir/src/Plugins/AbookAddressbook/main.cpp.obj Now some garbage, just for completeness, feel free to not read this: [turbo-hipster@ci-el7-big-1 build]$ make VERBOSE=1 be.contacts /usr/bin/cmake -H/home/turbo-hipster/pwn-trojita/trojita -B/home/turbo-hipster/pwn-trojita/trojita/build --check-build-system CMakeFiles/Makefile.cmake 0 make -f CMakeFiles/Makefile2 be.contacts make[1]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -H/home/turbo-hipster/pwn-trojita/trojita -B/home/turbo-hipster/pwn-trojita/trojita/build --check-build-system CMakeFiles/Makefile.cmake 0 /usr/bin/cmake -E cmake_progress_start /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles 7 make -f CMakeFiles/Makefile2 CMakeFiles/be.contacts.dir/all make[2]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' make -f CMakeFiles/be.contacts_automoc.dir/build.make CMakeFiles/be.contacts_automoc.dir/depend make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' cd /home/turbo-hipster/pwn-trojita/trojita/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/be.contacts_automoc.dir/DependInfo.cmake --color= make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make -f CMakeFiles/be.contacts_automoc.dir/build.make CMakeFiles/be.contacts_automoc.dir/build make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles [ 0%] Automoc for target be.contacts /usr/bin/cmake -E cmake_automoc /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/be.contacts_automoc.dir/ AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AbookAddressbook/main.cpp make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles [ 0%] Built target be.contacts_automoc make -f CMakeFiles/Plugins_automoc.dir/build.make CMakeFiles/Plugins_automoc.dir/depend make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' cd /home/turbo-hipster/pwn-trojita/trojita/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/Plugins_automoc.dir/DependInfo.cmake --color= make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make -f CMakeFiles/Plugins_automoc.dir/build.make CMakeFiles/Plugins_automoc.dir/build make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles [ 0%] Automoc for target Plugins /usr/bin/cmake -E cmake_automoc /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/Plugins_automoc.dir/ AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AddressbookPlugin.cpp AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/PasswordPlugin.cpp AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/PluginJob.cpp AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/PluginManager.cpp AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AddressbookPlugin.h AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/PasswordPlugin.h AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/PluginJob.h AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/PluginManager.h make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles [ 0%] Built target Plugins_automoc make -f CMakeFiles/Plugins.dir/build.make CMakeFiles/Plugins.dir/depend make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' cd /home/turbo-hipster/pwn-trojita/trojita/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/Plugins.dir/DependInfo.cmake --color= make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make -f CMakeFiles/Plugins.dir/build.make CMakeFiles/Plugins.dir/build make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' make[3]: Nothing to be done for `CMakeFiles/Plugins.dir/build'. make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles 81 82 83 [ 42%] Built target Plugins make -f CMakeFiles/trojita_plugin_AbookAddressbookPlugin_automoc.dir/build.make CMakeFiles/trojita_plugin_AbookAddressbookPlugin_automoc.dir/depend make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' cd /home/turbo-hipster/pwn-trojita/trojita/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/trojita_plugin_AbookAddressbookPlugin_automoc.dir/DependInfo.cmake --color= make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make -f CMakeFiles/trojita_plugin_AbookAddressbookPlugin_automoc.dir/build.make CMakeFiles/trojita_plugin_AbookAddressbookPlugin_automoc.dir/build make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles 98 [ 57%] Automoc for target trojita_plugin_AbookAddressbookPlugin /usr/bin/cmake -E cmake_automoc /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/trojita_plugin_AbookAddressbookPlugin_automoc.dir/ AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AbookAddressbook/AbookAddressbook.cpp AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AbookAddressbook/be-contacts.cpp AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AbookAddressbook/AbookAddressbook.h AUTOMOC: Checking /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AbookAddressbook/be-contacts.h make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles 98 [ 57%] Built target trojita_plugin_AbookAddressbookPlugin_automoc make -f CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/build.make CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/depend make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' cd /home/turbo-hipster/pwn-trojita/trojita/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/DependInfo.cmake --color= make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make -f CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/build.make CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/build make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' Linking CXX static library trojita_plugin_AbookAddressbookPlugin.a /usr/bin/cmake -P CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/cmake_clean_target.cmake /usr/bin/cmake -E cmake_link_script CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/link.txt --verbose=1 /usr/bin/i686-w64-mingw32-ar cr trojita_plugin_AbookAddressbookPlugin.a CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/src/Plugins/AbookAddressbook/AbookAddressbook.cpp.obj CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/src/Plugins/AbookAddressbook/be-contacts.cpp.obj CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/trojita_plugin_AbookAddressbookPlugin_automoc.cpp.obj /usr/bin/i686-w64-mingw32-ranlib trojita_plugin_AbookAddressbookPlugin.a make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles 96 97 [ 85%] Built target trojita_plugin_AbookAddressbookPlugin make -f CMakeFiles/be.contacts.dir/build.make CMakeFiles/be.contacts.dir/depend make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' cd /home/turbo-hipster/pwn-trojita/trojita/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles/be.contacts.dir/DependInfo.cmake --color= make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make -f CMakeFiles/be.contacts.dir/build.make CMakeFiles/be.contacts.dir/build make[3]: Entering directory `/home/turbo-hipster/pwn-trojita/trojita/build' /usr/bin/cmake -E cmake_progress_report /home/turbo-hipster/pwn-trojita/trojita/build/CMakeFiles Here we go: [ 85%] Building CXX object CMakeFiles/be.contacts.dir/src/Plugins/AbookAddressbook/main.cpp.obj /usr/bin/i686-w64-mingw32-g++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_STATICPLUGIN -DQT_STRICT_ITERATORS -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_QSTRINGBUILDER -DQT_WIDGETS_LIB -Wall -Wsign-compare -O2 -std=c++11 -O3 -DNDEBUG @CMakeFiles/be.contacts.dir/includes_CXX.rsp -o CMakeFiles/be.contacts.dir/src/Plugins/AbookAddressbook/main.cpp.obj -c /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AbookAddressbook/main.cpp Sounds legit, but doesn't help. Linking CXX executable be.contacts.exe /usr/bin/cmake -E cmake_link_script CMakeFiles/be.contacts.dir/link.txt --verbose=1 /usr/bin/cmake -E remove -f CMakeFiles/be.contacts.dir/objects.a /usr/bin/i686-w64-mingw32-ar cr CMakeFiles/be.contacts.dir/objects.a @CMakeFiles/be.contacts.dir/objects1.rsp /usr/bin/i686-w64-mingw32-g++ -Wall -Wsign-compare -O2 -std=c++11 -O3 -DNDEBUG -mwindows -Wl,--whole-archive CMakeFiles/be.contacts.dir/objects.a -Wl,--no-whole-archive -o be.contacts.exe -Wl,--out-implib,libbe.contacts.dll.a -Wl,--major-image-version,0,--minor-image-version,0 libtrojita_plugins.dll.a trojita_plugin_AbookAddressbookPlugin.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Widgets.dll.a libtrojita_plugins.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Gui.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Core.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libqt5main.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 CMakeFiles/be.contacts.dir/objects.a(main.cpp.obj):main.cpp:(.text.startup+0x4): undefined reference to `qt_static_plugin_trojita_plugin_AbookAddressbookPlugin()' collect2: error: ld returned 1 exit status make[3]: *** [be.contacts.exe] Error 1 make[3]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make[2]: *** [CMakeFiles/be.contacts.dir/all] Error 2 make[2]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make[1]: *** [CMakeFiles/be.contacts.dir/rule] Error 2 make[1]: Leaving directory `/home/turbo-hipster/pwn-trojita/trojita/build' make: *** [be.contacts] Error 2 > (The next question would be whether it makes its path down) What do you mean?
It's supposed to be defined in trojita_plugin_AbookAddressbookPlugin.a, assuming there's no dynamic variant flying around and falsely being picked by the compiler: readelf -sW trojita_plugin_AbookAddressbookPlugin.a | grep trojita_plugin (just that this is probably no ELF file? ;-)
Comparing outputs of objdump on a native Linux system and on this mingw cross compilation, I'm getting some qt_static_plugin_* symbols in my Linux' ./CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/trojita_plugin_AbookAddressbookPlugin_automoc.cpp.o, but when I take a look at mingw' ./CMakeFiles/trojita_plugin_AbookAddressbookPlugin.dir/trojita_plugin_AbookAddressbookPlugin_automoc.cpp.obj, there's nothing like that. Going further, the moc_AbookAddressbook.cpp on the broken mingw build indeed doesn't contain stuff like QT_PLUGIN_METADATA_SECTION or QT_MOC_EXPORT_PLUGIN. This is super-weird, given that it's invoked like this: Generating moc_AbookAddressbook.cpp /usr/i686-w64-mingw32/bin/qt5/moc -I/home/turbo-hipster/pwn-trojita/trojita/src -I/home/turbo-hipster/pwn-trojita/trojita/build -I/usr/i686-w64-mingw32/sys-root/mingw/include -I/usr/i686-w64-mingw32/sys-root/mingw/include/qt5 -I/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore -I/usr/i686-w64-mingw32/sys-root/mingw/share/qt5/mkspecs/win32-g++ -I/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtWidgets -I/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtGui -DQT_STATICPLUGIN -DBUILD_PLUGIN -DQT_CORE_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_CORE_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_STRICT_ITERATORS -DQT_USE_QSTRINGBUILDER -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -o /home/turbo-hipster/pwn-trojita/trojita/build/moc_AbookAddressbook.cpp /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AbookAddressbook/AbookAddressbook.h More weird things -- stuff starts working once again when I remove this from the moc's invocation: -I/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore So, in other words, the following invocation of moc actually produces a usable result: /usr/i686-w64-mingw32/bin/qt5/moc -I/home/turbo-hipster/pwn-trojita/trojita/src -I/home/turbo-hipster/pwn-trojita/trojita/build -I/usr/i686-w64-mingw32/sys-root/mingw/include -I/usr/i686-w64-mingw32/sys-root/mingw/include/qt5 -I/usr/i686-w64-mingw32/sys-root/mingw/share/qt5/mkspecs/win32-g++ -I/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtWidgets -I/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtGui -DQT_STATICPLUGIN -DBUILD_PLUGIN -DQT_CORE_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_CORE_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_STRICT_ITERATORS -DQT_USE_QSTRINGBUILDER -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -o mgw-without-mgwqt5core /home/turbo-hipster/pwn-trojita/trojita/src/Plugins/AbookAddressbook/AbookAddressbook.h I double-checked this; if I leave that path in the moc's invocation, the resulting .cpp doesn't contain the static plugin data. When I kill it, the static plugin data are there. Time to sleep, I guess, because this doesn't make any sense.
/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore/qplugin.h defines QT_MOC_EXPORT_PLUGIN depending on QT_STATICPLUGIN definition. I assume this happens in some other path (qt5/mkspecs/win32-g++ , include/qt5/QtWidgets , /include/qt5/QtGui) as well, but "corrected" (some windows speciality or similar) which is shadowed by the qplugin.h in QtCore. Alternatively "some" header in include/qt5/QtCore undefines QT_STATICPLUGIN (it should only show up in qplugin.h)
So this was actually caused by the Qt4 installation. Hint: [turbo-hipster@ci-el7-big-1 ~]$ grep -R QT_STATICPLUGIN /usr/i686-w64-mingw32/sys-root/mingw/include /usr/i686-w64-mingw32/sys-root/mingw/include/Qt/qplugin.h:#if defined(QT_STATICPLUGIN) /usr/i686-w64-mingw32/sys-root/mingw/include/QtCore/qplugin.h:#if defined(QT_STATICPLUGIN) /usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore/qplugin.h:#if defined(QT_STATICPLUGIN) [turbo-hipster@ci-el7-big-1 ~]$ rpm -qf /usr/i686-w64-mingw32/sys-root/mingw/include/Qt/qplugin.h mingw32-qt-4.8.6-8.el7.noarch Removing that package fixed the build problem.