what does the $ld$add$os10.4$ prefix mean when I use nm to look at a symbol list on a Mac?

蓝咒 提交于 2019-12-06 07:28:57

$ld$add$osXX.X$SYMBOL is a linker directive that allows one to redirect symbol resolution in a library. The command sits in the __DATA section of a binary and is parsed by ld at link time to change the visibility of exported symbols. The linker on OS X actually accepts quite a few different kinds of these commands:

$ld$hide$osXX.X$SYMBOL Adds that symbol to the ignore set. The Linker will no longer export that symbol to any binaries that link with the library even though it may have global visibility.

$ld$add$osXX.X$SYMBOL Adds that symbol to the binary at link time regardless of whether a definition exists.

$ld$install_name$osXX.X Redirects the definition of a symbol in a particular binary to another binary. This is used to work around an issue in OS X where CoreGraphics used to exist as a sub-framework of ApplicationServices. All symbols are now redirected around to the proper framework.

$ld$compatibility_version Forces compatibility with earlier versions of the Linker.

In your case, you've bumped up against a compatibility issue in Foundation. OS X exported NSFileWrapper in AppKit until 10.7 when the symbol was hidden from there and moved to Foundation. Normally, this means the author of AppKit would hide the _OBJC_CLASS_$, _OBJC_METACLASS_$, and _OBJC_IVAR_$ parts of a class definition to make the linker look elsewhere for that symbol. However, because you removed the -fobjc-abi-version flag the compiler defaults back to the old 1.x ABI which only requires the hiding and finding of a .objc_class_name which probably don't exist in the binary you're trying to link.

As for your undefined symbols, it's a simple file extension issue. .cpp are c++ only files, (which means no NSRunloop, MSMutableArray, NSObject, etc). If you wish to access these objects, rename the offending files with the extension .mm, which is a standard objC++ file. It's also a good idea to link against and import QuartzCore (for EAGL2View) and UIKit (for UIScreen and friends along with UIAccelerometer).

I'm not really clued up on the iOS SDK, but why are you compiling for "i386"?. I ran into this similar problem a few nights ago while playing with PhoneGap. I just removed "i386" from my XCode project settings and everything seemed to work fine in the simulator after that. Though i could be wrong.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!