[cfe-dev] libclang cannot find its resource dir on linux?
silvas at purdue.edu
Tue Jan 7 17:13:16 PST 2014
This is a known problem for external tools and is a huge pain. The
underlying problem is that the resource dir is looked up relative to the
current executable. This works fine for clang which is installed in the
right place so that this works.
The exact path that it looks up relative to the executable can be found in
CompilerInvocation::GetResourcesPath in lib/Frontend/CompilerInvocation.cpp
Here are 3 ways to work around this:
1. Put your executable in the same place as the clang binary.
2. Copy/symlink the resource dir to the same relative location from your
executable as they are from the clang binary.
3. Pass the argument `-resource-dir /path/to/resource/dir`. It is a `clang
-cc1` argument so you need to use the `-Xclang` prefix to pass it, i.e.
`-Xclang -resource-dir -Xclang /path/to/resource/dir`.
-- Sean Silva
On Tue, Jan 7, 2014 at 7:59 AM, Erik Verbruggen <erik.verbruggen at me.com>wrote:
> I have a small test program that behaves differently on linux and mac:
> CXIndex idx = clang_createIndex(1, 1);
> struct CXUnsavedFile unsaved;
> unsaved.Filename = "tst.c";
> unsaved.Contents = "#include <xmmintrin.h>\n";
> unsaved.Length = strlen(unsaved.Contents);
> CXTranslationUnit tu = clang_parseTranslationUnit(idx, "tst.c", 0, 0,
> unsaved, 1, 0);
> On macos, the translation unit is fine: when running clang_getInclusions
> on it, I get the full path of xmmintrin.h. However, on linux this fails
> with "tst.c:1:10: fatal error: 'xmmintrin.h' file not found". Running it on
> the command-line works fine though.
> So, is this expected behaviour, or a bug?
> -- Erik.
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev