Bug 459344 - Fails to compile (link) when built statically
Summary: Fails to compile (link) when built statically
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kfilemetadata
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Alexander Lohnau
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-18 18:55 UTC by Dawid Wróbel
Modified: 2022-09-24 09:02 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dawid Wróbel 2022-09-18 18:55:08 UTC
SUMMARY
See this pipeline run for details: https://invent.kde.org/frameworks/kfilemetadata/-/jobs/485282

 97%] Linking CXX executable ../bin/externalwritertest
/usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld: ../lib/libKF5FileMetaData.a(mocs_compilation.cpp.o): in function `KFileMetaData::ExternalWriter::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)':
/builds/frameworks/kfilemetadata/_build/src/KF5FileMetaData_autogen/EWIEGA46WW/moc_externalwriter.cpp:59: multiple definition of `KFileMetaData::ExternalWriter::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)'; CMakeFiles/externalwritertest.dir/externalwritertest_autogen/mocs_compilation.cpp.o:/builds/frameworks/kfilemetadata/_build/autotests/externalwritertest_autogen/VNU7RW3YIC/moc_externalwriter.cpp:59: first defined here
/usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld: ../lib/libKF5FileMetaData.a(mocs_compilation.cpp.o):(.data.rel.ro.local+0x60): multiple definition of `KFileMetaData::ExternalWriter::staticMetaObject'; CMakeFiles/externalwritertest.dir/externalwritertest_autogen/mocs_compilation.cpp.o:(.data.rel.ro+0x60): first defined here
/usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld: ../lib/libKF5FileMetaData.a(mocs_compilation.cpp.o): in function `KFileMetaData::ExternalWriter::metaObject() const':
/builds/frameworks/kfilemetadata/_build/src/KF5FileMetaData_autogen/EWIEGA46WW/moc_externalwriter.cpp:77: multiple definition of `KFileMetaData::ExternalWriter::metaObject() const'; CMakeFiles/externalwritertest.dir/externalwritertest_autogen/mocs_compilation.cpp.o:/builds/frameworks/kfilemetadata/_build/autotests/externalwritertest_autogen/VNU7RW3YIC/moc_externalwriter.cpp:77: first defined here
/usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld: ../lib/libKF5FileMetaData.a(mocs_compilation.cpp.o): in function `KFileMetaData::ExternalWriter::qt_metacast(char const*)':
/builds/frameworks/kfilemetadata/_build/src/KF5FileMetaData_autogen/EWIEGA46WW/moc_externalwriter.cpp:82: multiple definition of `KFileMetaData::ExternalWriter::qt_metacast(char const*)'; CMakeFiles/externalwritertest.dir/externalwritertest_autogen/mocs_compilation.cpp.o:/builds/frameworks/kfilemetadata/_build/autotests/externalwritertest_autogen/VNU7RW3YIC/moc_externalwriter.cpp:82: first defined here
/usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld: ../lib/libKF5FileMetaData.a(mocs_compilation.cpp.o): in function `KFileMetaData::ExternalWriter::qt_metacall(QMetaObject::Call, int, void**)':
/builds/frameworks/kfilemetadata/_build/src/KF5FileMetaData_autogen/EWIEGA46WW/moc_externalwriter.cpp:90: multiple definition of `KFileMetaData::ExternalWriter::qt_metacall(QMetaObject::Call, int, void**)'; CMakeFiles/externalwritertest.dir/externalwritertest_autogen/mocs_compilation.cpp.o:/builds/frameworks/kfilemetadata/_build/autotests/externalwritertest_autogen/VNU7RW3YIC/moc_externalwriter.cpp:90: first defined here
/usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld: ../lib/libKF5FileMetaData.a(mocs_compilation.cpp.o):(.bss+0x4c2): multiple definition of `__odr_asan._ZN13KFileMetaData14ExternalWriter16staticMetaObjectE'; CMakeFiles/externalwritertest.dir/externalwritertest_autogen/mocs_compilation.cpp.o:(.bss+0x340): first defined here
Comment 1 Alexander Lohnau 2022-09-19 19:51:32 UTC
This might be trickier, but I will give it a look :)
Comment 3 Alexander Lohnau 2022-09-24 09:02:00 UTC
Git commit b25af779834ae88b45b8e2d529cdb5636930e2ab by Alexander Lohnau.
Committed on 24/09/2022 at 08:21.
Pushed by wrobelda into branch 'master'.

Fix compilation of tests in static builds

If we build statically, we can not add the source files twice, because then we have duplicated symbols.

Though for shared builds we need it, because the classes are not exported.

M  +2    -2    autotests/CMakeLists.txt

https://invent.kde.org/frameworks/kfilemetadata/commit/b25af779834ae88b45b8e2d529cdb5636930e2ab