[cfe-dev] 'Header file not found' error during clang source to source transformation

Joshua Cranmer 🐧 Pidgeot18 at gmail.com
Thu Jun 19 20:10:48 PDT 2014


On 6/19/2014 2:46 PM, Sandeep K Chaudhary wrote:
> Hi guys,
>
> I am doing some basic source to source transformation by iterating 
> through the AST using Clang front-end. And, it is working fine i.e. I 
> am able to get transformed code with insertions.
>
> However, when I have some header file inclusions in the input source 
> code such as "#include<stdio.h", it produces an error message when 
> transforming the code. It is -
>
> *input.c:1:9: fatal error: 'stdio.h' file not found*
> *#include<stdio.h>*
> *        ^*
> So my question is - how can I avoid getting this error about header 
> files? For all practical use, my input source files will have the 
> header files. Please let me know.
>

This is a well-known issue that is unfortunately documented extremely 
poorly (or, rather, the documentation does absolutely nothing to call 
out what is arguably the single most common failure beyond "I'm missing 
-I or -l in my compile commands").

The short version: drop your tool in /usr/local/bin and run it from there.

The longer version: in the absence of specific options indicating 
otherwise, the lookup for files usually found in places under /usr is 
done using $(dirname argv[0])/../lib/clang/<version>/include and similar 
paths.

-- 
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140619/99eda9b7/attachment.html>


More information about the cfe-dev mailing list