xcode 未找到 -llib 的库。(clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用))

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25239257/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:22:02  来源:igfitidea点击:

Library not found for -llib. (clang: error: linker command failed with exit code 1 (use -v to see invocation))

iosxcodeclanglinker-errors

提问by Imran

I am working on a project that was previously done and uploaded on app store.When I run this app in Xcode 5.0 it is working fine but when I run this on Xcode Version 5.1.1 (5B1008) I am getting Linker error on both device and simulator.

我正在处理一个以前完成并上传到应用程序商店的项目。当我在 Xcode 5.0 中运行这个应用程序时它工作正常但是当我在 Xcode 版本 5.1.1 (5B1008) 上运行它时我在两个设备上都收到链接器错误和模拟器。

Error Message- Library not found for -llib. (clang: error: linker command failed with exit code 1 (use -v to see invocation)).

错误消息 -未找到 -llib 的库。(clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用))

I have searched a lot but I didn't get any thread about Library not found for -lliberror. Is there anything I have to change in build settings to resolve this?

我已经搜索了很多,但我没有得到任何关于Library not found for -llib错误的线索。我需要在构建设置中更改什么才能解决这个问题吗?

回答by trojanfoe

Look at the linker command line in detail for the -Loptions being used:

详细查看链接器命令行以了解-L正在使用的选项:

enter image description here

在此处输入图片说明

Then use Terminalor Finderto see if your libXXX.afile exists in those directories. If the library exists elsewhere then you need to configure your Library Search Paths:

然后使用终端Finder查看您的libXXX.a文件是否存在于这些目录中。如果库存在于其他地方,则您需要配置库搜索路径

enter image description here

在此处输入图片说明

However there several details which you have not provided in your question when using a library within an app:

但是,在应用程序中使用库时,您没有在问题中提供一些详细信息:

  • Is the library built as part of the Xcode project/workspace (as in the first image)?
  • Is the library supplied by a third-party with binary (.a) and header files (as in the second image)?
  • 该库是否作为 Xcode 项目/工作区的一部分构建(如第一张图片所示)?
  • 第三方提供的库是否带有二进制 ( .a) 和头文件(如第二张图片所示)?

回答by Chris

TL;DR: I ran makein the wrong directory so the paths were messed up.

TL;DR:我运行make在错误的目录中,所以路径被搞乱了。

Problem:

问题:

>make
linking ../build/release/yubikey-personalization-gui
/usr/x86_64-suse-linux/bin/ld: cannot find -llib
...

I ran into this when compiling the Yubikey Personalisation Tool. I tracked down the -llibcall in my Makefilewhich looked like this:

我在编译 Yubikey 个性化工具时遇到了这个问题。我-llib在我的电话中Makefile找到了如下所示的电话:

...
LINK = @echo linking $@ && g++
...
LIBS = $(SUBLIBS)  -L/usr/lib64 -L../lib/release -llib -lyubikey -lykpers-1 -lQtGui -L/usr/lib64 -L/usr/X11R6/lib -lQtCore -lpthread 
...
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

So it was setting a variable called LINKwhich would print "linking" and then call g++, which is the compiler. Then it set the var LIBSwhich would hold the ominous -llib. Then it composes and runs the command $(LINK) ... $(LIBS). Which runs g++with the parameter -llib.

因此,它设置了一个名为的变量LINK,该变量将打印“链接”,然后调用g++,即编译器。然后它设置LIBS将持有不祥-llib. 然后它编写并运行命令$(LINK) ... $(LIBS)g++使用参数运行-llib

And what does that do? Turns out -l<something>is telling the compiler to use the something-library. So it asks for the library called libhere. Which is strangely generic. I figured out that the sources came with a directory called lib/, which was at ../lib.

那有什么作用呢?结果-l<something>是告诉编译器使用something-library。所以它要求调用lib这里的库。这是奇怪的通用。我发现源文件带有一个名为 的目录lib/,位于../lib.

So starting makefrom a directory higher up fixed it.

所以make从更高的目录开始修复它。

回答by iosMentalist

You should remove libstdc++ from other linker flags in your xcode project

您应该从 xcode 项目中的其他链接器标志中删除 libstdc++

https://stackoverflow.com/a/53103383/1344237

https://stackoverflow.com/a/53103383/1344237