开发者

Getting list of linked libraries form cocoa code

On my application starting I need to get list of libraries that are linked to it. Unfortunately, I could't find any example 开发者_开发问答in cocoa how can I do it from code. Can anybody help me with this?


So, there's probably a better way than this (and this is completely untested written-into-this-text-field code), but I think this would do the trick:

uint32_t imageCount = _dyld_image_count();
char **names = calloc(sizeof(char *), imageCount);
int32_t *versions = calloc(sizeof(int32_t), imageCount);
for (uint32_t idx = 0; idx < imageCount; idx++) {
    names[idx] = _dyld_get_image_name(idx);
    versions[idx] = NSVersionOfLinkTimeLibrary(names[idx]);
}

If I'm understanding dyld.h properly, this should get you a list of all the currently loaded mach-o images and their link-time versions. Any mach-o image with a link-time version of -1 wasn't linked against from the main executable.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜