Page MenuHomePhorge

Fix export macros on non-Linux systems
AbandonedPublic

Authored by rakuco on Sep 13 2016, 10:59 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 23, 10:16 PM
Unknown Object (File)
Feb 9 2024, 2:21 AM
Unknown Object (File)
Jan 30 2024, 8:06 AM
Unknown Object (File)
Jan 26 2024, 5:25 AM
Unknown Object (File)
Jan 26 2024, 5:24 AM
Unknown Object (File)
Jan 26 2024, 5:24 AM
Unknown Object (File)
Jan 19 2024, 6:56 AM
Unknown Object (File)
Dec 30 2023, 8:59 AM
Subscribers
None

Details

Summary

At the moment, building any application that links against libkolab on
FreeBSD fails because of missing symbols. For example, building
kolabformatchecker throws the following error messages:

CMakeFiles/kolabformatchecker.dir/kolabformatchecker.cpp.o: In function `main':
/tmp/libkolab/utils/kolabformatchecker.cpp:95: undefined reference to `Kolab::KolabObjectReader::KolabObjectReader(boost::shared_ptr<KMime::Message> const&)'
/tmp/libkolab/utils/kolabformatchecker.cpp:105: undefined reference to `Kolab::KolabObjectReader::~KolabObjectReader()'
/tmp/libkolab/utils/kolabformatchecker.cpp:105: undefined reference to `Kolab::KolabObjectReader::~KolabObjectReader()'
CMakeFiles/kolabformatchecker.dir/kolabformatchecker.cpp.o: In function `Kolab::ErrorHandler::instance()':
/tmp/libkolab/./kolabformat/errorhandler.h:64: undefined reference to `Kolab::ErrorHandler::ErrorHandler()'
CMakeFiles/kolabformatchecker.dir/kolabformatchecker.cpp.o: In function `Kolab::ErrorHandler::errorOccured()':
/tmp/libkolab/./kolabformat/errorhandler.h:86: undefined reference to `Kolab::ErrorHandler::error() const'

The direct cause for the issue is the fact that Q_DECL_IMPORT is an
empty macro on most non-Windows compilers in Qt4 (this has been fixed in
Qt5), and the workaround in kolab_export.h was only defined for Linux.

Using a broader #ifdef check does fix the issue, but there is one other
things we can improve: nothing in the code defines MAKE_KOLAB_LIB, so
KOLAB_EXPORT was never set to Q_DECL_EXPORT (which is also likely why
the Q_DECL_IMPORT workaround was added in the first place). We can check
for kolab_EXPORTS instead: it's a macro defined by CMake itself when a
shared library is being built, which is exactly what we want.

The Q_DECL_IMPORT hack is still useful though, as omitting it can cause
problems with dynamic_cast, exceptions and anything that requires a
typeinfo lookup.

Test Plan

Building libkolab's utils/ on FreeBSD works, and so does kdepim-runtime.

Diff Detail

Repository
rLK libkolab
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

rakuco retitled this revision from to Fix export macros on non-Linux systems.
rakuco updated this object.
rakuco edited the test plan for this revision. (Show Details)
rakuco added reviewers: mollekopf, vanmeeuwen.
rakuco set the repository for this revision to rLK libkolab.

I think this is no longer relevant since we only build with qt5 now.

Sorry that it took 4 years to address this at all, this did go poorly.

If you think the patch is still relevant at all, let me know (otherwise I'd rather not break what works).