我在OS X上创建了一个Photoshop插件(基本上是一个Bundle / DyLib)。
我使用英特尔编译器并通过链接OpenMP(libiomp5
)来使用OpenMP
当我使用静态链接时,它会崩溃Photoshop(仅在OS X上,在Windows上它可以工作)
所以我尝试了动态链接。
主机Photoshop自己使用libiomp5.dylib
,它在Framework文件夹中可用
所以,在Xcode上我设置链接部分Runpath Search Paths
到@executable_path/../Frameworks/
但是当我尝试在Photoshop上加载它时它不会工作。
我还尝试将Runpath Search Paths
设置为Intel Run Time Redistributable Libraries(其中包括根据MacDependency插件所需的所有DyLib,就像Photoshop的框架库一样)但它仍然赢得了#39} ;加载Photoshop。
当我在插件上使用otool -L时,我得到:
/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中插入的内容:
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
设置为Intel Run Time Redistributable Libraries,我也会看到正确的路径,但结果是一样的。
有人可以帮助我吗? 我不是很熟悉开发人员,所以一步一步会很棒。
答案 0 :(得分:2)
对于了解@rpath的现代图书馆,您的解决方案是正确的。 OpenMP库支持@rpath启动编译器版本16.0更新2.在您的情况下,您的RPATH设置被系统忽略
您可以尝试使用photoshop中的openmp库进行链接吗?据我所知,他们为此做了一个解决方法,并将libiomp5.dylib中的install_name更新为“@executable_path /../ Frameworks / libiomp5.dylib”。因此,如果您链接到该库,“otool -l”输出中的openmp名称将更改为@executable_path /../ Frameworks / libiomp5.dylib
一些提示
如果photoshop更新通过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用法
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
- 弗拉基米尔