您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页解决库移位出现的 ld: library not found f

解决库移位出现的 ld: library not found f

来源:伴沃教育

在Pod里,有个第三方库不更新了,但是里面的警告挺多的,开发组老大让我把它单独挪出来,把警告处理掉,期间遇到了一个坑,于是就有了这篇文章。

如约,Pods工程目录下,把Posfile里的那个库注释掉,然后:

pod install

回车,

Analyzing dependencies
Removing XXX 
...

然后把XXX拖进项目另一个工程目录下,commond+ B,出现error:

"xxx.h" file  no find

出现这个这个正常,因为有缓存,于是shift + cmmond + k,清除缓存,再commod + B,重新编译。

这个时候,本文重点描述的幺蛾子error出现了:

ld: library not found for -lXXXXX(XXXX就是对应的库名称)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决方法:
查找网络资源:

第二篇里面提到Link binary With LibrariesLibrary Search Path,但是都没有解决目前这个问题。但是已经很接近error的真相了:依赖路径不对。

这里的处理方式是:

在主项目中打开Build Settings -> Other Link Flags 打开以后,发现里面存在对应的库名称,前面还有一个前缀修饰: -lxxx。把它干掉。

commod + R

屏幕显示:


Never say never

摘录如下:

Q: here are three different search paths in XCode Build Settings:

  • Framework Search Path
  • Header Search Path
  • Library Search Path
    Could anyone clarify what those paths do and what they are used for?

In Mac development, it's set automatically if you drag a 3rd party framework into the project. Otherwise, just set it to the container directory where you saved the framework.

In xcconfig files you use this variable:

FRAMEWORK_SEARCH_PATHS = "/path/to/frameworks/container/directory"

Header search path: where to search for header files (.h files) in addition to system paths. Usually you'll need it if you are using a 3rd party library. Set it to the directory where you have the header files. If you use a directory to include the header (example: #import "mylibrary/component.h") set it to the parent directory.

In xcconfig files you use this variable:

HEADER_SEARCH_PATHS = "/path/to/headers/container/directory"

Library search path: where to search for library files in addition to system paths. Xcode will set it automatically if you drag a library (.a files) into the project. To set it manually, use the directory where the library is located.

In xcconfig files you use this variable:

LIBRARY_SEARCH_PATHS = "/path/to/libraries/container/directory" 

All three can hold a list of paths, with quotes, separated by space.

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务