Xcode不断在错误的路径上搜索dylib [英] Xcode keeps searching dylib at wrong path

查看:84
本文介绍了Xcode不断在错误的路径上搜索dylib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那是我的错误:

dyld: Library not loaded: /usr/local/lib/libofa.0.dylib
Referenced from: /sers/david/Projekte/Test/build/Debug/Test.app/Contents/MacOS/Test
Reason: image not found

我已经进行了一些研究,并使用install_name_tool更改了dylib中的路径:

I've done some research and changed the path inside the dylib with install_name_tool:

davids-macbook:Test david$ otool -L libofa.0.0.0.dylib 
libofa.0.0.0.dylib:
@executable_path/../Frameworks/libofa.0.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)

但是Xcode一直在/usr/lib/中搜索它:

But Xcode keeps searching for it in /usr/lib/:

build/Debug/Test.app/Contents/MacOS/Test:
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 15.0.0)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0)
/opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
@executable_path/../Frameworks/TagLib.framework/Versions/A/TagLib (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/QTKit.framework/Versions/A/QTKit (compatibility version 1.0.0, current version 1.0.0)
/opt/local/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 7.2.0)
/System/Library/Frameworks/Quartz.framework/Versions/A/Quartz (compatibility version 1.0.0, current version 1.0.0)
/opt/local/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/local/lib/libofa.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 103.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.29.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 751.29.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1038.32.0)

有没有办法在Xcode中设置它???谢谢

Is there a way to set this in Xcode??? Thanks

编辑:该库不是Xcode项目.它使用./configure构建;做

The library is not a Xcode project. Its build with ./configure; make

推荐答案

通常我是这样做的:

  1. 将库的安装目录设置为 @rpath .这会将安装名称设置为@rpath/libofa.0.0.0.dylib.如果您自己构建库,则可以在Xcode中进行设置.否则,请使用install_name_tool进行更改.
  2. 使用库将应用程序的运行路径搜索路径设置为包含该库的目录的位置.例如,如果将库放在应用程序的Frameworks目录中,则可以将 Runpath搜索路径设置为 @executable_path/../Frameworks (或 @loader_path/../Frameworks >).
  1. Set the Installation Directory of the library to @rpath. This will set the install name to @rpath/libofa.0.0.0.dylib. If you're building the library yourself, you can set this in Xcode; otherwise, use install_name_tool to change it.
  2. Set the Runpath Search Paths of the application using the library to the location of the directory containing the library. For example, if you put the library in the app's Frameworks directory, you'd set Runpath Search Paths to @executable_path/../Frameworks (or @loader_path/../Frameworks).

此博客文章这一个详细介绍

这篇关于Xcode不断在错误的路径上搜索dylib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆