Xcode“找不到选项-L的目录”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20480571/
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
Xcode "directory not found for option -L" errors
提问by soleil
I'm getting these errors:
我收到这些错误:
ld: warning: directory not found for option '-L"/pathToMyApp/MyApp/Shared/Libraries/ADMS_AppLibrary"'
ld: warning: directory not found for option '-L"/pathToMyApp/MyApp/Shared/Libraries/TestFlightSDK1.1"'
ld: warning: directory not found for option '-L"/pathToMyApp/MyApp/Shared/Libraries/Medialets"'
ld: library not found for -lTestFlight
clang: error: linker command failed with exit code 1 (use -v to see invocation)
These directories do in fact exist at the paths above.
这些目录确实存在于上面的路径中。
The thing is, the app used to compile fine. All I did was add a new version of the Medialets library to the project, and now I get these erros.
问题是,该应用程序用于编译良好。我所做的只是在项目中添加了一个新版本的 Medialets 库,现在我得到了这些错误。
回答by Ketan
There is two errors that people seem to be confused with
人们似乎混淆了两个错误
If it is a "directory not found for option '-L/..." error That means it's a Library Error, and you should try to:
如果它是“找不到选项 '-L/... 的目录”错误这意味着它是一个库错误,您应该尝试:
Click on your project (targets) Click on Build Settings Under Library Search Paths, delete the paths If it is a "directory not found for option '-F/..." That means it's a Framework Error, and you should try to:
单击您的项目(目标)单击库搜索路径下的构建设置,删除路径如果它是“找不到选项'-F / ...的目录”这意味着这是一个框架错误,您应该尝试:
Click on your project (targets) Click on Build Settings Under Frameworks Search Paths, delete the paths
单击您的项目(目标)单击 Frameworks Search Paths 下的 Build Settings,删除路径
回答by Taka
I had the same problem when I added a new library to the project.
当我向项目添加新库时,我遇到了同样的问题。
It seems that the linker error occurs when the Xcode 5 adds a path to "Library Search Paths" automatically when adding a new library directory to the project.
当 Xcode 5 在向项目添加新库目录时自动添加到“库搜索路径”的路径时,似乎会发生链接器错误。
The linker error disappeared once I manually edited the paths. (I didn't essentially change the path, just tried some different formats such as $(PROJECT_DIR)/path/to/library or "$(SRCROOT)/path/to/library". It worked even after changed back to the original format.)
一旦我手动编辑了路径,链接器错误就消失了。(我基本上没有改变路径,只是尝试了一些不同的格式,例如 $(PROJECT_DIR)/path/to/library 或“$(SRCROOT)/path/to/library”。即使改回原始格式也能工作格式。)
I think it's a bug of Xcode. I'm using Xcode 5.1 (5B130a).
我认为这是Xcode的一个错误。我使用的是 Xcode 5.1 (5B130a)。
回答by Chandu kumar.Alasyam
ld: warning: directory not found for option '-L"----it's a Library Error
ld:警告:找不到选项“-L”的目录----这是一个库错误
Select your projectgo to the Build Settingstab,Under Library Search Paths, Replace the path with this string $(SRCROOT)
选择您的项目,转到Build Settings选项卡,在Library Search Paths 下,将路径替换为此字符串$(SRCROOT)
回答by kalmiya
For the "-L" issue,
对于“-L”问题,
If you are using cmake (in my case 3.3.2) and use the xcode generator, it will generate multiple entries for each link-directory you specify,
如果您使用 cmake(在我的情况下为 3.3.2)并使用 xcode 生成器,它将为您指定的每个链接目录生成多个条目,
link_directories ("${PROJECT_SOURCE_DIR}/SDKs/thelib/lib")
see the cmake sourcecode, cmGlobalXCodeGenerator::AddDependAndLinkInformation(...) where it does this:
请参阅 cmake 源代码,cmGlobalXCodeGenerator::AddDependAndLinkInformation(...),它执行以下操作:
{ ...
if(this->XcodeVersion > 15)
{
// Now add the same one but append
// $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
linkDirs += " ";
linkDirs += this->XCodeEscapePath((*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str());
}
linkDirs += " ";
linkDirs += this->XCodeEscapePath(libDir->c_str());
}
which will result in XCode having these entries in the Lib Search Path
这将导致 XCode 在 Lib 搜索路径中包含这些条目
/Users/myuser/thelib/lib/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
/Users/myuser/thelib/lib
So that makes it a bit more difficult to get rid of this warning; Depending on your file-structure, one of those is likely going to be wrong - and even if you manually remove it they will be back next time your project is regenerated.
所以这使得摆脱这个警告有点困难;根据您的文件结构,其中一个可能会出错 - 即使您手动删除它,它们也会在您下次重新生成项目时返回。
One work-around is to just create empty directories for the ones it complains about...
一种解决方法是为它抱怨的目录创建空目录......
It's also possible to "pass some arguments" to the linker using "-Wl", but so far I didn't find out what to pass to silence that specific warning.
也可以使用“-Wl”向链接器“传递一些参数”,但到目前为止我还没有找到传递什么来使该特定警告静音。
回答by whyoz
Just removing the lib from "Link With Binary With Libraries" section of "Build Phases" doesn't seem to resolve the issue in Xcode 6 at least.
仅从“构建阶段”的“与二进制链接”部分中删除 lib 似乎至少不能解决 Xcode 6 中的问题。
1) Go to your project navigator and find the "Frameworks" folder
1)转到您的项目导航器并找到“Frameworks”文件夹
2) your lib is probably there already, so just right click and "Delete"
2)您的库可能已经存在,所以只需右键单击并“删除”
3) Select "Remove References"
3)选择“删除引用”
4) go to your repo or project folder where all your files are and drag it into the "Frameworks" folder
4)转到所有文件所在的存储库或项目文件夹并将其拖到“Frameworks”文件夹中
5) clean, and rebuild and the errors should go away
5)清理,重建,错误应该消失