开发者

How can I isolate third-parties' C/C++/ObjC libraries' symbols from each other?

I have a project that needs to incorporate two third-party libraries, libA and libB. I have little, if any, influence over the third-party libraries. The problem being is that both libA and libB include different versions of a common library, ASIHTTPRequest. As a result, I'm getting errors like:

-[ASIFormDataRequest setNumberOfTimesToRetryOnTimeout:]: unrecognized selector sent to instance 0x3b4170

, which I can only assume are because libA is referring to libB's implementation of ASIHTTPRequest (or the other way around).

I've tried playing around with strip -s <symbol file> -u <library> to isolate the libraries' symbols from each other, but that results in XCode's linker spitting out thousands of warnings and doesn't actually fix the main problem outlined above.

ld: warning: can'开发者_JAVA百科t add line info to anonymous symbol anon-func-0x0 from ...

In general, how can/should one isolate libraries from each other?


There is absolutely no way to do so. One Objective-C application can have only one meaning for one symbol at a time. If you load two different versions of one library the last one will overwrite the first one.

Two workarounds:

  1. convince the developer to use a recent version
  2. run both libraries in separate processes


If they used the same linker symbol name for different routines, the only way out (short of hacking their object files), is to link them into different executables somehow.

On platforms that support dynamic linking (eg: DLLs) you could build one or both into a separate DLL. If they aren't part of the exported interface the symbols shouldn't clash then.

Otherwise you would be stuck putting them into entirely separate processes and using IPC to pass data between them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜