Calling function by name using dlsym in iOS

守給你的承諾、 提交于 2019-12-04 13:38:55

I believe the problem is that dlopen is not supported on iOS, even if you statically link your libraries. You should be able to use

dlsym(RTLD_SELF, "getstring");

because RTLD_SELF means 'start looking in the image that called dlsym'. Based on how you're using dlopen() it should accomplish the same thing.

I've actually had some successful experiences in a case similar to yours. I used dlsym(RTLD_MAIN_ONLY, "getstring") to get the function pointer.

Note that your getstring symbol must be suitable for dynamic linking: this can be checked using

nm -m <application>

Your symbol must be external (not non-external).

I'm not yet too sure about the procedure to ensure that symbols are marked as external.

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