SUMMARY When compiling statically (-DBUILD_SHARED_LIBS=OFF), I am getting the following linker error with clang: duplicate symbol 'KPackage::PackageJobThread::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'KPackage::PackageJobThread::qt_metacall(QMetaObject::Call, int, void**)' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'KPackage::PackageJobThread::metaObject() const' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'KPackage::PackageJobThread::percentChanged(int)' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'KPackage::PackageJobThread::jobThreadFinished(bool, QString const&)' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'KPackage::PackageJobThread::error(QString const&)' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'KPackage::PackageJobThread::installPathChanged(QString const&)' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'KPackage::PackageJobThread::qt_metacast(char const*)' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'KPackage::PackageJobThread::staticMetaObject' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'vtable for KPackage::PackageJobThread' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'typeinfo name for KPackage::PackageJobThread' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) duplicate symbol 'typeinfo for KPackage::PackageJobThread' in: src/kpackagetool/CMakeFiles/kpackagetool5.dir/kpackagetool5_autogen/mocs_compilation.cpp.o lib/libKF5Package.a(mocs_compilation.cpp.o) ld: 12 duplicate symbols for architecture arm64 STEPS TO REPRODUCE 1. attempt to build with SHARED LIBS off OBSERVED RESULT Fails to link due to duplicate symbols EXPECTED RESULT Should build just fine (it used to) SOFTWARE/OS VERSIONS macOS: 12.6 (21G115) Qt Version: 5.15.6
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kpackage/-/merge_requests/55
Git commit c9d1f3dcd9432f9855d53cc9e51587195fb15106 by Alexander Lohnau. Committed on 14/09/2022 at 16:20. Pushed by alex into branch 'master'. Fix duplicate symbol in static builds By linking KPackage against the kpackagetool5 executable and compiling these two private files again, we end up with duplicated symbols. To fix this, we can put then in a static library that we link in KPackage and kpackagetool5 against. M +8 -2 src/kpackage/CMakeLists.txt M +1 -3 src/kpackagetool/CMakeLists.txt https://invent.kde.org/frameworks/kpackage/commit/c9d1f3dcd9432f9855d53cc9e51587195fb15106