Bug 459099 - Static compilation fails
Summary: Static compilation fails
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kpackage
Classification: Frameworks and Libraries
Component: default (show other bugs)
Version: 5.98.0
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Alexander Lohnau
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-14 13:47 UTC by Dawid Wróbel
Modified: 2022-09-14 16:20 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dawid Wróbel 2022-09-14 13:47:29 UTC
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
Comment 1 Bug Janitor Service 2022-09-14 13:58:38 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kpackage/-/merge_requests/55
Comment 2 Alexander Lohnau 2022-09-14 16:20:58 UTC
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