设置插件的搜索路径(捆绑包/DyLib) [英] Setting the Search Path for Plug In (Bundle / DyLib)
问题描述
我正在OS X(基本上是捆绑软件/DyLib)上创建Photoshop插件.
我正在使用Intel Compiler,并通过链接到OpenMP(libiomp5
)使用OpenMP.
当我使用静态链接时,它会使Photoshop崩溃(仅在OS X和Windows上有效).
所以我尝试了动态链接.
I'm creating a Photoshop Plug In on OS X (Basically a Bundle / DyLib).
I'm using Intel Compiler and uses OpenMP by linking against OpenMP (libiomp5
).
When I use Static Linking it crashes Photoshop (Only on OS X, on Windows it works).
So I tried dynamic linking.
主机Photoshop单独使用libiomp5.dylib
,该文件位于其Framework文件夹中.
因此,在Xcode上,我在链接部分上将Runpath Search Paths
设置为@executable_path/../Frameworks/
,但是当我尝试将其加载到Photoshop时,它将无法正常工作.
我还尝试将Runpath Search Paths
设置为 Intel Run时间可再分发库(根据 MacDependency ,其中包括插件所需的所有DyLib,就像Photoshop的Framework库),但仍不会在Photoshop上加载.
The host, Photoshop, uses by itself libiomp5.dylib
which is available on its Framework folder.
So, on Xcode I set on the Linking Part the Runpath Search Paths
to @executable_path/../Frameworks/
yet when I try to load it on Photoshop it won't work.
I also tried to set Runpath Search Paths
to Intel Run Time Redistributable Libraries (Which include all DyLib needed for the Plug In according to MacDependency, just like Photoshop's Framework library) yet still it won't load on Photoshop.
当我在插件上使用otool -L时,我得到:
When I use otool -L on the Plug In, I get:
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
libimf.dylib (compatibility version 0.0.0, current version 0.0.0)
libsvml.dylib (compatibility version 0.0.0, current version 0.0.0)
libirng.dylib (compatibility version 0.0.0, current version 0.0.0)
libiomp5.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
libintlc.dylib (compatibility version 1.0.0, current version 1.13.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 62.0.0)
当我在插件上尝试otool -l
时,我确实看到了我在Xcode中插入的内容:
When I tried otool -l
on the Plug In I do see what I insert in Xcode:
Load command 6
cmd LC_UUID
cmdsize 24
uuid B61F2961-AD6D-30B9-AF58-C67689731966
Load command 7
cmd LC_VERSION_MIN_MACOSX
cmdsize 16
version 10.7
sdk 10.10
Load command 8
cmd LC_LOAD_DYLIB
cmdsize 88
name /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 157.0.0
compatibility version 2.0.0
Load command 9
cmd LC_LOAD_DYLIB
cmdsize 40
name libimf.dylib (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 0.0.0
compatibility version 0.0.0
Load command 10
cmd LC_LOAD_DYLIB
cmdsize 40
name libsvml.dylib (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 0.0.0
compatibility version 0.0.0
Load command 11
cmd LC_LOAD_DYLIB
cmdsize 40
name libirng.dylib (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 0.0.0
compatibility version 0.0.0
Load command 12
cmd LC_LOAD_DYLIB
cmdsize 40
name libiomp5.dylib (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 5.0.0
compatibility version 5.0.0
Load command 13
cmd LC_LOAD_DYLIB
cmdsize 48
name /usr/lib/libc++.1.dylib (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 120.0.0
compatibility version 1.0.0
Load command 14
cmd LC_LOAD_DYLIB
cmdsize 56
name /usr/lib/libSystem.B.dylib (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 1213.0.0
compatibility version 1.0.0
Load command 15
cmd LC_LOAD_DYLIB
cmdsize 40
name libintlc.dylib (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 1.13.0
compatibility version 1.0.0
Load command 16
cmd LC_LOAD_DYLIB
cmdsize 104
name /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (offset 24)
time stamp 2 Thu Jan 1 02:00:02 1970
current version 62.0.0
compatibility version 1.0.0
Load command 17
cmd LC_RPATH
cmdsize 48
path @executable_path/../Frameworks/ (offset 12)
Load command 18
cmd LC_FUNCTION_STARTS
cmdsize 16
dataoff 3486976
datasize 5616
Load command 19
cmd LC_DATA_IN_CODE
cmdsize 16
dataoff 3492592
datasize 0
如果将Runpath Search Paths
设置为英特尔运行时可再分发库,我也会看到正确的路径,但结果是相同的.
If I set the Runpath Search Paths
to Intel Run Time Redistributable Libraries I see the proper path as well, yet the result is the same.
有人可以帮我吗?
我不是非常有经验的开发人员,因此,一步一步就好了.
Could anyone assist me with that?
I'm not very experience developer so, step by step would be great.
推荐答案
您的解决方案对于意识到@rpath的现代库是正确的. OpenMP库支持@rpath,开始于16.0更新版本2的编译器.在这种情况下,系统会将RPATH设置忽略
Your solution is correct for modern libraries that are aware of @rpath. OpenMP library supports @rpath starting compiler version 16.0 update 2. In your case your RPATH settings are ignored by system
您可以尝试从photoshop与with with openmp库链接吗?据我了解,他们为此做了一个解决方法,并将install_name从libiomp5.dylib更新为"@executable_path/../Frameworks/libiomp5.dylib".因此,如果您链接到该库,则"otool -l"输出中的openmp名称将更改为@executable_path/../Frameworks/libiomp5.dylib
Can you try to link with the with openmp library from photoshop? as I understand they did a workaround for this and updated install_name from libiomp5.dylib to "@executable_path/../Frameworks/libiomp5.dylib". so if you link to that library the openmp name in "otool -l" output will be changed to @executable_path/../Frameworks/libiomp5.dylib
一些提示
-
如果photoshop通过install_name_tool更新安装名称
If photoshop updates install name via install_name_tool
$ otool -l ./a.out | grep omp
name libiomp5.dylib (offset 24)
# libiomp5.dylib was copied to the location with test
$ install_name_tool -id "@executable_path/../Frameworks/libiomp5.dylib" libiomp5.dylib
$ LIBRARY_PATH=.:$LIBRARY_PATH icc -openmp test1.cpp
$ otool -l ./a.out | grep omp
name @executable_path/../Frameworks/libiomp5.dylib (offset 24)
RPATH用法
RPATH usage
install_name_tool -id "@executable_path/../Frameworks/libiomp5.dylib" libiomp5.dylib
$ LIBRARY_PATH=.:$LIBRARY_PATH icc -openmp test1.cpp -Wl,-rpath,.
$ ./a.out
dyld: Library not loaded: @executable_path/../Frameworks/libiomp5.dylib
Referenced from: /nfs/inn/home/vpolin/mac/./a.out
Reason: image not found
Trace/BPT trap: 5
$ install_name_tool -id "@rpath/libiomp5.dylib" libiomp5.dylib
$ LIBRARY_PATH=.:$LIBRARY_PATH icc -openmp test1.cpp -Wl,-rpath,.
$ otool -l ./a.out | grep omp
name @rpath/libiomp5.dylib (offset 24)
$ ./a.out
4 8 8 8 8
-弗拉基米尔
这篇关于设置插件的搜索路径(捆绑包/DyLib)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!