84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
hello.app/Frameworks/dym.framework dlopen的第一个参数path应该怎么设置才能正确加载Frameworks/dym.framework/dym文件?
光阴似箭催人老,日月如移越少年。
两个project: dym -> dym.framework hello -> hello.app hello.app动态链接dym.framework
关于动态链接的xcode设置有以下几个变量: @rpath hello项目中,Run Path search paths的值,基本格式如下: //:configuration = Debug LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/Frameworks //:configuration = Release LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/Frameworks
@loader_path 根据apple doc的解析,是使用加载共享库的二进制文件所在的目录 比如, hello.app/hello会加载dym.framework/dym,则@loader_path指向hello.app目录
@executable_path 根据app包中的可执行文件所在的目录;
dym项目需要设置: Dynamic Library Install Name Base: @rpath 这样, Dynamic Library install Name, 默认设置 $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH) 就会显示成 @rpath/dym.framework/dym 那么,编译生成的动态库文件中,会保存对应的install name信息
hello项目的设置,只需要设置Run Path search paths即可, 编译完成后,会将path参数的信息保存到hello的目标文件的RPATH中, 程序运行的时候,会在RPATH指定的路径下,查找动态库的install name; 关于rpath在编译器中是怎么生成的,可以参考这里。
使用dlopen打开的时候,会根据@rapth指定的路径,查找动态库, 使用以下格式就可以打开: dlopen(“./dym.framework/dym”, RTLD_LAZY);
你的framework应该被包含在app里面。然后用[NSBundle mainBundle] pathForResource系列的函数把路径搞出来。
两个project:
dym -> dym.framework
hello -> hello.app
hello.app动态链接dym.framework
关于动态链接的xcode设置有以下几个变量:
@rpath
hello项目中,Run Path search paths的值,基本格式如下:
//:configuration = Debug
LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/Frameworks
//:configuration = Release
LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/Frameworks
@loader_path
根据apple doc的解析,是使用加载共享库的二进制文件所在的目录
比如, hello.app/hello会加载dym.framework/dym,则@loader_path指向hello.app目录
@executable_path
根据app包中的可执行文件所在的目录;
dym项目需要设置:
Dynamic Library Install Name Base: @rpath
这样, Dynamic Library install Name, 默认设置
$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)
就会显示成
@rpath/dym.framework/dym
那么,编译生成的动态库文件中,会保存对应的install name信息
hello项目的设置,只需要设置Run Path search paths即可, 编译完成后,会将path参数的信息保存到hello的目标文件的RPATH中, 程序运行的时候,会在RPATH指定的路径下,查找动态库的install name; 关于rpath在编译器中是怎么生成的,可以参考这里。
使用dlopen打开的时候,会根据@rapth指定的路径,查找动态库, 使用以下格式就可以打开:
dlopen(“./dym.framework/dym”, RTLD_LAZY);
你的framework应该被包含在app里面。然后用[NSBundle mainBundle] pathForResource系列的函数把路径搞出来。