macos xcode4:链接器错误:找不到选项的目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8912551/
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-10-21 08:46:48  来源:igfitidea点击:

xcode4: Linker error: Directory not found for option

macosxcode4buildlinker

提问by akbuildmaster

I'm getting this error for my profile build (debug build was OK).

我的配置文件构建出现此错误(调试构建正常)。

{Directory not found for option '-L../../../Mac/Profile/lib [full path of that directory]

Library not found for -lMyLib}

When I check the path, the directory exists and the lib file libMyLib.a exists as well. My library search path for the Profile build includes that directory $(SRCROOT)/../../../Mac/Profile/lib. I also made sure that the library was built under profile setting.

当我检查路径时,该目录存在并且 lib 文件 libMyLib.a 也存在。我的 Profile 构建的库搜索路径包括该目录 $(SRCROOT)/../../../Mac/Profile/lib。我还确保库是在配置文件设置下构建的。

This only happens with profile build.

这只发生在配置文件构建中。

I'd really love to have some help although it may well be a no-brainer question.

我真的很想得到一些帮助,尽管这很可能是一个不费吹灰之力的问题。

Thank you!

谢谢!

EDIT: Found the solution myselfSolved the problem: In my linker path, there were two directory entries. The second one was surrounded by double quotes while the first one wasn't. Xcode4 seems to have concatenated them into a single directory entry and apparently that was garbage. After I removed the quotation marks, the linker error was gone.

编辑:自己找到了解决方案解决了问题:在我的链接器路径中,有两个目录条目。第二个被双引号包围,而第一个没有。Xcode4 似乎已将它们连接到一个目录条目中,显然这是垃圾。删除引号后,链接器错误消失了。

回答by duongvanthai

Go to "Get Info" on the target. Click the "Build Settings" tab (i'm using Xcode4), and scroll down to "Search Paths", Where You delete all the values in "Library Search Paths".

转到目标上的“获取信息”。单击“构建设置”选项卡(我使用的是 Xcode4),然后向下滚动到“搜索路径”,删除“库搜索路径”中的所有值。

Hope that helps...

希望有帮助...

回答by Marc

There are two errors that people seem to have confused

人们似乎混淆了两个错误

If it is a "directory not found for option '-L/..." That means it's a Library Error, and you might want to try:

如果它是“找不到选项 ' -L/... 的目录”,则表示这是一个库错误,您可能想尝试:

  • Click on your project (targets)
  • Click on Build Settings
  • Under Library Search Paths, delete the paths
  • 单击您的项目(目标)
  • 点击构建设置
  • 在 Library Search Paths 下,删除路径

If it is a "directory not found for option '-F/..." That means it's a Framework Error, and you might want to try:

如果它是“找不到选项 ' -F/... 的目录”,则意味着它是框架错误,您可能想尝试:

  • Click on your project (targets)
  • Click on Build Settings
  • Under Framework Search Paths, delete the paths
  • 单击您的项目(目标)
  • 点击构建设置
  • 在 下Framework Search Paths,删除路径

This might happen when you move referenced files around or change the project folder name.

当您四处移动引用文件或更改项目文件夹名称时,可能会发生这种情况。

回答by Ian Newland

It was similar as above in the Library Search Paths. I found that one of my paths was missing quotes around it...

它与上述图书馆搜索路径中的类似。我发现我的其中一条路径缺少引号...

// Old path
$(PROJECT_DIR)/Google Analytics

// New path
"$(PROJECT_DIR)/Google Analytics"

回答by simon_smiley

I came across this error in seemingly a completely different scenario from those answers above. Hopefully some people will do what I did and find this useful even if it is a rare occurence.

我在与上述答案完全不同的情况下遇到了这个错误。希望有些人会做我所做的事情并发现这很有用,即使这种情况很少见。

I managed to get this error after having just added a new viewController to my project. As normal I added a tableview and constrained it then added and linked the delegate and datasource. I also created a property.

在我的项目中添加了一个新的 viewController 后,我设法得到了这个错误。像往常一样,我添加了一个 tableview 并对其进行了约束,然后添加并链接了委托和数据源。我还创建了一个属性。

The weird thing that I then noticed was that as soon as I finished creating the property it was immediately linked, as if I had linked it, but before I linked it. When I clicked on the xib file and checked the links it wasn't in fact linked to the table view.

然后我注意到的奇怪的事情是,一旦我完成创建属性,它就会立即链接,好像我已经链接了它,但在我链接它之前。当我单击 xib 文件并检查链接时,它实际上并未链接到表视图。

enter image description here

在此处输入图片说明

(This link appeared automatically without me needing to create it myself)

(此链接自动出现,无需我自己创建)

I don't know why this happened. I deleted the file and remade it with the same name but it just happened again. Giving me this error above.

我不知道为什么会这样。我删除了该文件并使用相同的名称重新制作它,但它又发生了。给我上面这个错误。

The way I solved it was to create a new file, different name, and added and created the links in a different order checking at each step that this hadn't occurred. After doing this no linked created themselves and it worked.

我解决它的方法是创建一个新文件,不同的名称,并以不同的顺序添加和创建链接,检查每一步是否发生这种情况。这样做之后,没有链接自己创建并且它起作用了。

TL DR: If you are getting this error and have recently added new view controller then check if deleting it works and if so they remake it being careful about any automatic links.

TL DR:如果您收到此错误并且最近添加了新的视图控制器,请检查删除它是否有效,如果有效,他们会重新制作它,注意任何自动链接。