Clang 工具 (libtooling):将标头搜索路径设置为标准库标头.基础框架

related link http://kevinaboos.wordpress.com/2013/07/23/clang-tutorial-part-ii-libtooling-example

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>());

and next parameters:

llvm/Debug+Asserts/bin/mytool  /somePath/someSource.mm -- 

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:

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

after --

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 sources are placed in the folder called Headers, so clang cannot find them. So, i'am going to find solution for that issue.

UPDATE:

solution

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/

相关文章