[Interest] Objective C Category for QCocoaApplicationDelegate undefined symbols

Croitor Alexandru placinta at gmail.com
Thu Jul 2 13:42:56 CEST 2015


Hi.

I'm trying to add an Objective C category to the QCocoaApplicationDelegate
class that is defined by the Mac OS X Cocoa platform plugin, to add /
override some methods.
The QCocoaApplicationDelegate is defined in Qt's source folder
"src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h".

My code for the category is as simple as this:

// Code in osx_app_delegate.mm

#include <qglobal.h>

#include <Cocoa/Cocoa.h>


@interface QCocoaApplicationDelegate

@end


@interface QCocoaApplicationDelegate (AppDelegate)

@end



@implementation QCocoaApplicationDelegate (AppDelegate)

@end


But when I try to compile the code, I get the following error:

Undefined symbols for architecture x86_64:

"_OBJC_CLASS_$_QCocoaApplicationDelegate", referenced from:

l_OBJC_$_CATEGORY_QCocoaApplicationDelegate_$_AppDelegate in
osx_app_delegate.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see
invocation)


Doing the same (adding a category to the app delegate) on IOS works
properly.
I assume that is because the platform plugin on IOS is linked statically,
whereas on OSX it is linked dynamically.

I tried manually linking the cocoa plugin dylib file at link stage like so:

 LIBS += -L/Users/X/Dev/Qt/5.4/clang_64/plugins/platforms -lqcocoa


But this doesn't help either.
Is there no way to add the category if the platform plugin is dynamically
loaded?
Is the only option to statically compile Qt, and therefore the platform
plugin as well?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150702/8c68ab5b/attachment.html>


More information about the Interest mailing list