<html>
<head></head>
<body>
<blockquote class="replyBlock" style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex; color: #500050;"><p><br />There are some environment variables you can use, e.g, CPATH, etc. Please<br />take a look at the Environment section of this page for details, or look at<br />the:<br /><br /><a href="http://clang.llvm.org/docs/CommandGuide/clang.html" target="_blank">http://clang.llvm.org/docs/CommandGuide/clang.html</a></p>
</blockquote><p>Sorry, don hinton. I didn't see your message. Anyway, it doesn't work. I tried using these variables some time ago and I have used them again now, and "limits.h" is not found:</p>
<p>#if defined __GNUC__ && !defined _GCC_LIMITS_H_<br />/* `_GCC_LIMITS_H_' is what GCC's file defines. */<br /># include_next <limits.h><br />#endif</p>
<p>That's the problematic line in /usr/include/limits.h in my case.</p><br><br><div><em>El día 26 feb 2016 17:14, Pedro Delgado Perez <pedro.delgadoperez@mail.uca.es> escribió:</em></div><blockquote class="replyBlock" style="border-left: 2px solid #000044; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p><p>Thank you Mikhail and Jacob,<br/>
<br /> > So, the two vectors are filled with the header's name and content, attachedis the method I use to embed them. It isn't an ideal solution but it works.I created a small script that (more or less) automatically converts all thebuiltin headers to strings. If you want it, just let me know.</p>
<p><br />Right now, I don't understand why I need to convert the builtin headers to strings, but of course I would like to have a look to the script. Any help is very welcomed. You can send it directly to me email if you prefer.<br /><br /> > After both vectors are filled, I simply do (bold): </p>
<p>clang::tooling::FixedCompilationDatabase Compilations("./",compiler_string); <br/>
std::vector<std::string> sources; <br/>
sources.push_back("/esbmc_intrinsics.h"); <br/>
sources.push_back(path); </p>
<p>clang::tooling::ClangTool Tool(Compilations, sources); </p>
<p>Tool.mapVirtualFile("/esbmc_intrinsics.h", intrinsics); </p>
<p>for(auto it = clang_headers_name.begin(), it1 =clang_headers_content.begin(); <br/>
(it != clang_headers_name.end()) && (it1 !=clang_headers_content.end()); <br/>
++it, ++it1) <br/>
Tool.mapVirtualFile(*it, *it1);<br /><br />Ok, I catch the idea, but I have some doubts:<br />- "esbmc_intrinsics.h" is always that string? is that a real file?<br />- What are "path", "instrinsics" and "compiler_string" in your code?<br /><br />> As soon as clang 3.8 is released, we'll open source our project that usesthis code, so it'll be easier to understand how it's done. I hope thishelps for now.Also, You will need clang 3.8, as this doesn't work on clang 3.7.<br /><br />Could you tell me then how to obtain clang 3.8?<br /><br />Thanks again.</p><br><br><div><em>El día 26 feb 2016 14:06, Pedro Delgado Perez <pedro.delgadoperez@mail.uca.es> escribió:</em></div><blockquote class="replyBlock" style="border-left: 2px solid #000044; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p><p>Sorry about the format of the previous message. I write it again here.</p>
<br/>
<p>Sorry, Jacob, no idea on how to use your solution in my code. Manuel, nothing is written in your message I think...<br/>
My code is something like this:</p>
<p>static cl::OptionCategory MyToolCategory("My tool options");<br /><br /> int main(int argc, const char **argv) {<br /> CommonOptionsParser OptionsParser(argc, argv, MyToolCategory); <br /> ClangTool Tool(OptionsParser.getCompilations(), <br /> OptionsParser.getSourcePathList()); <br /> return Tool.run(newFrontendActionFactory<SyntaxOnlyAction>().get()); <br />}</p>
<p>What I was doing by the moment is to process argv before creating the object OptionsParser and then include internal Clang headers, but I guess I can't do that when using Json compilation database. Could you help me with that? Otherwise, is there a way to ship in the executable all the necessary headers so that the user does not require to have clang installed?</p>
<br/>
<p>Thanks.</p><br><br><div><em>El día 26 feb 2016 14:03, Pedro Delgado Perez <pedro.delgadoperez@mail.uca.es> escribió:</em></div><blockquote class="replyBlock" style="border-left: 2px solid #000044; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p><p>Sorry, Jacob, no idea on how to use your solution in my code. Manuel, nothing is written in your message I think...</p>
<p>My code is something like this:</p>
<pre class="fragment"><span class="keyword">static</span> cl::OptionCategory MyToolCategory(<span class="stringliteral">"My tool options"</span>);</pre><pre> int main(int argc, const char **argv) {<br /> <a title="A parser for options common to all command-line Clang tools." href="http://clang.llvm.org/doxygen/classclang_1_1tooling_1_1CommonOptionsParser.html">CommonOptionsParser</a> OptionsParser(argc, argv, MyToolCategory); <a title="Utility to run a FrontendAction over a set of files." href="http://clang.llvm.org/doxygen/classclang_1_1tooling_1_1ClangTool.html">ClangTool</a> Tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList()); return Tool.<a title="Runs an action over all files specified in the command line." href="http://clang.llvm.org/doxygen/classclang_1_1tooling_1_1ClangTool.html#acec91f63b45ac7ee2d6c94cb9c10dab3">run</a>(newFrontendActionFactory<SyntaxOnlyAction>().get()); }</pre><p>What I was doing by the moment is to process argv before creating the object OptionsParser and then include internal Clang headers, but I guess I can't do that when using Json compilation database. Could you help me with that? Otherwise, is there a way to ship in the executable all the necessary headers so that the user does not require to have clang installed?</p>
<p>Thanks.</p><br><br><div><em>El día 26 feb 2016 10:37, Pedro Delgado Perez <pedro.delgadoperez@mail.uca.es> escribió:</em></div><blockquote class="replyBlock" style="border-left: 2px solid #000044; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p><p>Hello,</p>
<p>Perhaps this question has been asked before, but I couldn't find a proper solution for this issue. When I produce an executable and use it in another machine, sometimes Clang is not able to find system header files (for instance "limits.h") because the paths to find these headers are relative to the location of the Clang libraries.</p>
<p>All the same, when I'm using FIXED COMPILATION, I'm able to automatically retrieve the paths to system headers of the machine where the executable is being run. I mean, I retrieve the paths and add them after "--" to the command through the option -isystem. However, when I'm using JSON COMPILATION DATABASE, I can't do that, so in this case I don't know how to solve this issue.</p>
<p>What is the appropriate manner to handle this matter of the paths to system header files?</p>
<p>Thanks.</p><br>
</p></blockquote>
</p></blockquote>
</p></blockquote>
</p></blockquote>
</body>
</html>