Xcode链接器错误:ld:找不到-twsapi的库 [英] Xcode linker error: ld: library not found for -twsapi

查看:141
本文介绍了Xcode链接器错误:ld:找不到-twsapi的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Makefile为 i386 架构编译并安装了一个库。该库位于 / usr / local / lib / twsapi 中,标题位于 / usr / local / include / twsapi

I have compiled and installed a library using Makefile for i386 architecture. The library is located in /usr/local/lib/twsapi and the headers are located in /usr/local/include/twsapi.

要在另一个项目中使用该库,我在构建设置>链接下添加了 libtwsapi.a Binary with Libraries,并向 HEADER_SEARCH_PATH 变量添加 / usr / local / include

To use that library in another project I have added libtwsapi.aunder Build Settings > Link Binary With Libraries, and added /usr/local/include to the HEADER_SEARCH_PATH variable.

在连接部分的构建过程失败,错误消息 ld:twsapi 找不到库,即使我已经引用了库。如果我删除二进制库的链接,我得到大量的错误像未定义的符号为架构i386:,这是有道理的,因为它找不到这种情况下的库。

The build process fails during the linking part with the error message ld: library not found for -twsapi even though I have referenced the library. If I remove the link to the binary library I get lots of errors like Undefined symbols for architecture i386:, which makes sense since it cannot find the library in that case. This confirms the library was indeed found in the first place.

任何想法发生了什么事?传递给链接器的参数如下所示:

Any ideas what's going on? The arguments passed to the linker are shown below:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ \
  -arch i386 \
  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk \
  -L/Users/morten/Library/Developer/Xcode/DerivedData/test_project-gwzyzroxzbyejngtpizlynumphvo/Build/Products/Debug \
  -L/usr/local/include \
  -L/usr/local/include/twsapi \
  -F/Users/morten/Library/Developer/Xcode/DerivedData/test_project-gwzyzroxzbyejngtpizlynumphvo/Build/Products/Debug \
  -F/usr/local/lib \
  -filelist /Users/morten/Library/Developer/Xcode/DerivedData/test_project-gwzyzroxzbyejngtpizlynumphvo/Build/Intermediates/test_project.build/Debug/test_project.build/Objects-normal/i386/test_project.LinkFileList \
  -mmacosx-version-min=10.9 \
  -stdlib=libc++ \
  -Xlinker \
  -dependency_info \
  -Xlinker /Users/morten/Library/Developer/Xcode/DerivedData/test_project-gwzyzroxzbyejngtpizlynumphvo/Build/Intermediates/test_project.build/Debug/test_project.build/Objects-normal/i386/test_project_dependency_info.dat \
  -o /Users/morten/Library/Developer/Xcode/DerivedData/test_project-gwzyzroxzbyejngtpizlynumphvo/Build/Products/Debug/test_project


推荐答案

未找到库。你的参数库确实发现在第一位是错误的,因为链接器从来没有到列表未定义的符号 - 它停止,因为无法找到所有指定的库。

The library is not being found. Your argument that "the library was indeed found in the first place" is faulty because the linker never gets to the point of listing undefined symbols - it halts upon not being able to find all specified libraries.

您的问题在链接器的这些参数中指定了搜索库的其他路径:

Your problem is in these arguments to the linker which specify additional paths to search for libraries:

-L/usr/local/include -L/usr/local/include/twsapi

/ usr / local / 包含的链接路径,而不是/ usr / local / lib

Note that you are specifying a link path of /usr/local/include and not /usr/local/lib which is where your library is.

您需要将/ usr / local / lib添加到Xcode中的库搜索路径以进行链接。标题搜索路径用于编译。从日志中看来,您在两个库中都有条目,但库搜索路径条目不正确。

You need to add /usr/local/lib to the Library Search Paths in Xcode for linking. The Header Search Paths is used for compiling. From the log it appears that you have entries in both but the Library Search Paths entry is incorrect.

这篇关于Xcode链接器错误:ld:找不到-twsapi的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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