Clang 工具 (libtooling):将标头搜索路径设置为标准库标头.基础框架 [英] Clang Tool (libtooling): set header search path to standard libs headers. Foundation framework

查看:155
本文介绍了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/

这篇关于Clang 工具 (libtooling):将标头搜索路径设置为标准库标头.基础框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆