Albert
Albert

Reputation: 68140

Symbol not found: _objc_retainAutoreleaseReturnValue in ARC-enabled dylib

I have an ARC-enabled application which dynamically loads a dylib via dlopen. The dylib is also ARC-enabled. Both are compiled with the MacOSX SDK 10.7 with deployment target 10.6.

At the dlopen, I get:

Symbol not found: _objc_retainAutoreleaseReturnValue
  Referenced from: /Users/bea/Downloads/MusicPlayer.app/Contents/Resources/Python/_guiCocoaCommon.dylib
  Expected in: /usr/lib/libobjc.A.dylib

This is kind of right because _objc_retainAutoreleaseReturnValue is not in /usr/lib/libobjc.A.dylib on MacOSX 10.6. But where is it?

How can I resolve this?

Upvotes: 2

Views: 390

Answers (1)

Albert
Albert

Reputation: 68140

The dlopen I used was with the RTLD_NOW flag. (I used it from within Python via ctypes.CDLL / ctypes._dlopen and RTLD_NOW is forced there.)

I guess you must use RTLD_LAZY on MacOSX because of this. When I use RTLD_LAZY, everything works fine (so far). It looks like as if the symbol _objc_retainAutoreleaseReturnValue is actually not used. So I wonder why it is there at all. Maybe this is a bug in Apples compiler. Edit: I think this explanation was wrong. I looked at the disassembly and it is used in one of my methods. But I guess it is replaced by the existing ___arclite_objc_retainAutoreleaseReturnValue at runtime which is also in the Dylib (so I guess libarclite_macosx.a is always automatically statically linked to it).

(I opened an issue about Python here. You can see my fix here.)

Upvotes: 1

Related Questions