Clang工具(libtooling):将标头搜索路径设置为标准libs标头.基础框架 [英] Clang Tool (libtooling): set header search path to standard libs headers. Foundation framework
问题描述
相关链接 http://kevinaboos. wordpress.com/2013/07/23/clang-tutorial-part-ii-libtooling-example
我正在使用CommonOptionsParser
来解析clang工具的参数:
I'am using CommonOptionsParser
to parse arguments for clang tool:
// parse the command-line args passed to your code
CommonOptionsParser op(argc, argv);
// create a new Clang Tool instance (a LibTooling environment)
ClangTool Tool(op.getCompilations(), op.getSourcePathList());
// run the Clang Tool, creating a new FrontendAction (explained below)
int result = Tool.run(newFrontendActionFactory<SomeAction>());
和下一个参数:
llvm/Debug+Asserts/bin/mytool /somePath/someSource.mm --
当我在某些源文件上运行我的工具(基于clang libtooling)时,该工具会尝试查找包含的文件,例如:
#import SomeClass.h
或#import<Foundation/Foundation.h>
When I run my tool (based on clang libtooling) on some source file, tool tries find included files, f.e:
#import "SomeClass.h"
, or #import<Foundation/Foundation.h>
如果找不到标题,则会产生错误:
And if it cannot find headers, it generates errors:
严重错误:找不到"Foundation/Foundation.h"文件.
fatal error: ‘Foundation/Foundation.h’ file not found.
如果您知道的话,您能告诉我如何将工具定向到标准框架吗?以及如何将其定向到某些标头搜索路径?运行工具时如何设置标题搜索路径?
Could you tell me, if you know, how can I direct tool to the standard frameworks? And How can I direct it to the some header search path? How can I set headers search path when running tool?
推荐答案
我已经解决了这个问题. 您可以使用选项
I've solved the issue. you can add path to framework with options
-Iinclude -Ipath_for_foundation/Headers
-Iinclude -Ipath_for_foundation/Headers
在--
llvm/Debug+Asserts/bin/mytool /somePath/someSource.mm -- -Iinclude -Ipath_for_foundation/Headers
但是,标准框架通常包含在框架名称中作为前缀
BUT, standard frameworks usually included with name of framework as prefixes
#import <Foundation/Foundation.h>
frameworks源文件放置在名为Headers
的文件夹中,因此clang无法找到它们.
因此,我将为该问题找到解决方案.
frameworks sources are placed in the folder called Headers
, so clang cannot find them.
So, i'am going to find solution for that issue.
更新:
解决方案
llvm/Debug+Asserts/bin/mytool /somePath/someSource.mm -- -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/
这篇关于Clang工具(libtooling):将标头搜索路径设置为标准libs标头.基础框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!