Youcompleteme: clang-c/Index.h error when running make ycm_core

Created on 5 Feb 2013  ·  17Comments  ·  Source: ycm-core/YouCompleteMe

YouCompleteMe/cpp/ycm/ClangCompleter/CompletionData.h:23:10: fatal error: 'clang-c/Index.h' file not found

include

     ^

1 error generated.
make[3]: ** [ycm/CMakeFiles/ycm_core.dir/CandidateRepository.cpp.o] Error 1
make[2]: *
* [ycm/CMakeFiles/ycm_core.dir/all] Error 2
make[1]: ** [ycm/CMakeFiles/ycm_core.dir/rule] Error 2
make: *
* [ycm_core] Error 2

Most helpful comment

Look in your cmake build directory. There should be a
ycm/CMakeFiles/ycm_core.dir/flags.make file that will list all of the
includes that are passed to your compiler. One of those flags should point
to the YouCompletMe/cpp/llvm/include folder (YCM has a copy of the clang
headers which it uses). There should be an absolute path to that folder
preceded by the -isystem flag.

On Tue, Feb 5, 2013 at 4:15 PM, stefan-w [email protected] wrote:

I'm getting this error also, with absolute and relative path, and also
after applying the patch from spice. This happens with system g++ and also
with clang++ from macports. Also on OS X 10.7.5.


Reply to this email directly or view it on GitHubhttps://github.com/Valloric/YouCompleteMe/issues/22#issuecomment-13160185.

All 17 comments

I've just got this. It was caused by CMake not finding Clang root directory relative to its build root.

Try absolute path.

I get the same error even when using an absolute root path. I’m however using a different C++ compiler (g++) since my system’s clang is too outdated to compile ycm_core correctly. For reference, here’s my step-by-step process to reproducing the problem:

# No change in downloading clang …
mkdir ~/ycm_build
cd ~/ycm_build
cmake -G "Unix Makefiles" -DCMAKE_CXX_COMPILER=g++ \
  -DPATH_TO_LLVM_ROOT=~/ycm_temp/clang+llvm-3.2-x86_64-apple-darwin11 \
  . ~/.vim/bundle/YouCompleteMe/cpp
make ycm_core

And the error I get is the same as OP’s:

[ 88%] Building CXX object ycm/CMakeFiles/ycm_core.dir/CandidateRepository.cpp.o
In file included from ~/.vim/bundle/YouCompleteMe/cpp/ycm/CandidateRepository.cpp:26:0:
~/.vim/bundle/YouCompleteMe/cpp/ycm/ClangCompleter/CompletionData.h:23:27: fatal error: clang-c/Index.h: No such file or directory

(g++ 4.7.2, OS X 10.7.5, up to date MacVim)

I'm getting this error also, with absolute and relative path, and also after applying the patch from spice. This happens with system g++ and also with clang++ from macports. Also on OS X 10.7.5.

Look in your cmake build directory. There should be a
ycm/CMakeFiles/ycm_core.dir/flags.make file that will list all of the
includes that are passed to your compiler. One of those flags should point
to the YouCompletMe/cpp/llvm/include folder (YCM has a copy of the clang
headers which it uses). There should be an absolute path to that folder
preceded by the -isystem flag.

On Tue, Feb 5, 2013 at 4:15 PM, stefan-w [email protected] wrote:

I'm getting this error also, with absolute and relative path, and also
after applying the patch from spice. This happens with system g++ and also
with clang++ from macports. Also on OS X 10.7.5.


Reply to this email directly or view it on GitHubhttps://github.com/Valloric/YouCompleteMe/issues/22#issuecomment-13160185.

Even better is to run with "make VERBOSE=1 ycm_core", it will give you the full command line.

@spice Thanks, I forgot about that.

Never mind, I’m an idiot – I used the folder name ycm_tmp instead of ycm_temp and didn’t adjust the cmake command line. It works now.

However, I wanted to point out that there is _no_ reference to YouCompletMe/cpp/llvm/include in my command line, and it isn’t necessary since the include path ~/ycm_temp/clang+llvm-3.2-x86_64-apple-darwin11/include also contains the required header.

I made the same error, so just ignore my reports too.

Hello. I think this post solved it at least partially for me. I blame Cmake for not testing for directories and such up front. Though it was interesting to try another build and configure system than GNU autotools. But autotools are better! :) But it is more laborious for the developer of course. Kudos to you for making this!

I think the installation would have been more user friendly if there was a test for the clang directory in the ycm_tmp folder.
:)

Reading the responses, it seems like this was configuration issue. Glad you all got it sorted out! :)

@klmr Yes, you can use the headers from the downloaded binary package. YCM has a copy so that the user can link to the system libclang even if there are no clang headers on his machine.

Hello.

I have never tried the cmake thing before. It looks easier to use than
GNU's configure system.

It is a great package you have there, it works great now that it is
installed. I still suggest that you test for the correct names of the
subdirectories the user is to install, or just provide an initial shell
script that makes them, that took over an hour for me to figure out.

Thanks a lot for a great package!

Tommy

2013/2/6 Val Markovic [email protected]

Reading the responses, it seems like this was configuration issue. Glad
you all got it sorted out! :)

@klmr https://github.com/klmr Yes, you can use the headers from the
downloaded binary package. YCM has a copy so that the user can link to the
system libclang even if there are no clang headers on his machine.


Reply to this email directly or view it on GitHubhttps://github.com/Valloric/YouCompleteMe/issues/22#issuecomment-13198610.

I know it's two years later, but I'm getting this error too. Followed the Windows install for mingw64 and clang exactly, but no luck. None of the above suggestions are working either.

having the same problem here in ubuntu 14.04 :/

Install LLVM、clang will solve it

I have the same problem in xubuntu 14.04:

[ 82%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/thread/src/pthread/once_atomic.cpp.o
[ 83%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/thread/src/pthread/thread.cpp.o
Linking CXX static library libBoostParts.a
[ 83%] Built target BoostParts
Scanning dependencies of target ycm_core
[ 83%] Building CXX object ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o
In file included from /home/mg/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/ClangCompleter/Location.h:22:0,
from /home/mg/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/ClangCompleter/Range.h:22,
from /home/mg/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/ClangCompleter/Diagnostic.h:22,
from /home/mg/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/ClangCompleter/ClangCompleter.h:23,
from /home/mg/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/ycm_core.cpp:23:
/home/mg/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/ClangCompleter/ClangUtils.h:21:27: fatal error: clang-c/Index.h: No such file or directory
#include
^
compilation terminated.
make[3]: ** [ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o] Error 1
make[2]: *
* [ycm/CMakeFiles/ycm_core.dir/all] Error 2
make[1]: *** [ycm/CMakeFiles/ycm_core.dir/rule] Error 2

now,i have

Very strange, was able to compile the libraries using
cmake --build . --target ycm_core --config Release but breaks when running./install.py --all
Have tried pretty much everything including brew install clang, checking @Valloric comment about the flags.make and much more but still no dice..

Marcuss-MacBook-Pro:youcompleteme marcus$ ./install.py --all
Searching Python 2.7 libraries...
Found Python library: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
Found Python headers folder: /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.7") 
-- Using libclang to provide semantic completion for C/C++/ObjC
-- Using external libclang: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /private/var/folders/yk/mn8vp4_s3dqdpmqzcjlxll_00000gn/T/ycm_build_BdWX1y
[50/76] Building CXX object ycm/CMakeFiles/ycm_core.dir/CandidateRepository.cpp.o
FAILED: ycm/CMakeFiles/ycm_core.dir/CandidateRepository.cpp.o 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -DUSE_CLANG_COMPLETER -DYCMD_CORE_VERSION=33 -DYCM_EXPORT="" -Dycm_core_EXPORTS -I/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm -I/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter -isystem /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/BoostParts -isystem /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -isystem "/usr/local/share/ycm-clang-llvm /include" -stdlib=libc++ -fcolor-diagnostics -fvisibility=hidden -O3 -DNDEBUG -fPIC   -std=c++11 -MD -MT ycm/CMakeFiles/ycm_core.dir/CandidateRepository.cpp.o -MF ycm/CMakeFiles/ycm_core.dir/CandidateRepository.cpp.o.d -o ycm/CMakeFiles/ycm_core.dir/CandidateRepository.cpp.o -c /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/CandidateRepository.cpp
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/CandidateRepository.cpp:25:
/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/CompletionData.h:22:10: fatal error: 'clang-c/Index.h' file not found
#include <clang-c/Index.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
[54/76] Building CXX object ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangCompleter.cpp.o
FAILED: ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangCompleter.cpp.o 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -DUSE_CLANG_COMPLETER -DYCMD_CORE_VERSION=33 -DYCM_EXPORT="" -Dycm_core_EXPORTS -I/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm -I/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter -isystem /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/BoostParts -isystem /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -isystem "/usr/local/share/ycm-clang-llvm /include" -stdlib=libc++ -fcolor-diagnostics -fvisibility=hidden -O3 -DNDEBUG -fPIC   -std=c++11 -MD -MT ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangCompleter.cpp.o -MF ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangCompleter.cpp.o.d -o ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangCompleter.cpp.o -c /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/ClangCompleter.cpp
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/ClangCompleter.cpp:18:
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/ClangCompleter.h:22:
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/Diagnostic.h:21:
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/Range.h:21:
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/Location.h:21:
/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/ClangUtils.h:21:10: fatal error: 'clang-c/Index.h' file not found
#include <clang-c/Index.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
[56/76] Building CXX object ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangHelpers.cpp.o
FAILED: ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangHelpers.cpp.o 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -DUSE_CLANG_COMPLETER -DYCMD_CORE_VERSION=33 -DYCM_EXPORT="" -Dycm_core_EXPORTS -I/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm -I/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter -isystem /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/BoostParts -isystem /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -isystem "/usr/local/share/ycm-clang-llvm /include" -stdlib=libc++ -fcolor-diagnostics -fvisibility=hidden -O3 -DNDEBUG -fPIC   -std=c++11 -MD -MT ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangHelpers.cpp.o -MF ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangHelpers.cpp.o.d -o ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangHelpers.cpp.o -c /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/ClangHelpers.cpp
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/ClangHelpers.cpp:18:
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/ClangHelpers.h:21:
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/Diagnostic.h:21:
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/Range.h:21:
In file included from /Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/Location.h:21:
/Users/marcus/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/ClangCompleter/ClangUtils.h:21:10: fatal error: 'clang-c/Index.h' file not found
#include <clang-c/Index.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
[57/76] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/winstances.cpp.o
ninja: build stopped: subcommand failed.
ERROR: the build failed.
Was this page helpful?
0 / 5 - 0 ratings