My system is Archlinux!
This problem has confused me for many mounth and it changed me from a C/C++ coder to a Golang coder!
What ever how to install the YCM,This problem will happen!
If i use the clang5,the YCM can't find the standard library.
I have no idea about other system!But in Archlinux,it is happening!
Such as
std::cout cant find!
std::string cant find!
std::vector cant find!
std::shared_ptr cant find!
...everything from std:: will be missed.However,clang works well,i can compile my program with it.
I have put all includes to my ".ycm_extra_conf.py" which from "echo | clang -v -x c++ -"
But nothing changed!
Here is some info YCM print out:
/usr/include/c++/7.2.1/cstdlib|75 col 15 error| 'stdlib.h' file not found
/usr/include/c++/7.2.1/bits/std_abs.h|38 col 15 error| 'stdlib.h' file not found
/usr/include/c++/7.2.1/bits/basic_string.h|6403 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6408 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6414 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6419 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6425 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6431 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6440 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6449 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6458 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6506 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6511 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6517 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6522 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6528 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6534 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6543 col 12 error| no matching function for call to '__to_xstring'
/usr/include/c++/7.2.1/bits/basic_string.h|6552 col 12 error| no matching function for call to '__to_xstring'
Projects/AYO_Server/AreYouOK.cpp|21 col 12 error| no member named 'cout' in namespace 'std'; did you mean 'count'? (FixIt available)
Projects/AYO_Server/AreYouOK.cpp|22 col 12 error| no member named 'cin' in namespace 'std'; did you mean 'min'? (FixIt available)
Projects/AYO_Server/AreYouOK.cpp|23 col 12 error| no member named 'cerr' in namespace 'std'
Projects/AYO_Server/AreYouOK.cpp|34 col 7 error| no template named 'shared_ptr' in namespace 'std'
Projects/AYO_Server/AreYouOK.cpp|34 col 18 error| use of undeclared identifier 'nolockqueue'
Projects/AYO_Server/AreYouOK.cpp|34 col 34 error| expected '(' for function-style cast or type construction
Projects/AYO_Server/AreYouOK.cpp|64 col 34 error| no member named 'shared_ptr' in namespace 'std'
Projects/AYO_Server/AreYouOK.cpp|64 col 45 error| 'userinfo' does not refer to a value
Projects/AYO_Server/AreYouOK.cpp|66 col 42 error| no member named 'shared_ptr' in namespace 'std'
Projects/AYO_Server/AreYouOK.cpp|90 col 16 error| implicit instantiation of undefined template 'std::basic_ifstream
Projects/AYO_Server/AreYouOK.cpp|118 col 2 error| use of undeclared identifier 'cout'; did you mean 'count'? (FixIt available)
Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_o89L49.log
-- Server Python interpreter: /usr/bin/python2
-- Server Python version: 2.7.14
-- Server has Clang support compiled in: True
-- Clang version: clang version 5.0.1 (tags/RELEASE_501/final)
-- Extra configuration file found and loaded
-- Extra configuration path: /usr/share/vim/vimfiles/bundle/Data/YouCompleteMe/.ycm_extra_conf.py
-- C-family completer debug information:
-- Compilation database path: None
-- Flags: ['-Wall', '-Wextra', '-Werror', '-fexceptions', '-DNDEBUG', '-std=c++11', '-x', 'c++', '-isystem', '/usr/inc
lude', '-isystem', '/usr/local/include', '-isystem', '/usr/lib/clang/5.0.1/include', '-isystem', '/usr/include/c++/7.2.1
', '-isystem', '/usr/include/c++/7.2.1/x86_64-pc-linux-gnu', '-isystem', '/usr/include/c++/7.2.1/backward', '-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1', '-isystem', '/Applicati
ons/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include', '-resource-dir=/usr/share/vim/vimfile
s/bundle/Data/YouCompleteMe/third_party/ycmd/ycmd/../clang_includes', '-fspell-checking']
-- Server running at: http://127.0.0.1:36297
-- Server process ID: 19442
-- Server logfiles:
-- /tmp/ycmd_36297_stdout_nYWpxX.log
-- /tmp/ycmd_36297_stderr_9R2Q7f.log
if i changed to use the clang39 or clang35 the problem will be fixed!
Help!
How can i fix this in Archlinux!
Help!
You should complete the issue template, not delete it.
With the bundled clang you need libtinfo5. Check AUR packages for that.
For system clang, try adding your system include paths to your flags.
@bstaletic
I have already add my include paths to my flag from the output of
"echo | clang -E -v -x c++ -"
nothing changed!
@bstaletic
the problem cant find libtinfo5.so solved!
but after that problem solved,it return to the problem 1!
what ever to do,what ever how to install the YCM!
YCM cant find the standard library!
What's the output of :YcmDebugInfo? Does the file /usr/include/c++/7.2.1/stdlib.h exist?
@micbou
Of course exist!
And the output of :YcmDebugInfo?
@micbou
Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_o89L49.log
-- Server Python interpreter: /usr/bin/python2
-- Server Python version: 2.7.14
-- Server has Clang support compiled in: True
-- Clang version: clang version 5.0.1 (tags/RELEASE_501/final)
-- Extra configuration file found and loaded
-- Extra configuration path: /usr/share/vim/vimfiles/bundle/Data/YouCompleteMe/.ycm_extra_conf.py
-- C-family completer debug information:
-- Compilation database path: None
-- Flags: ['-Wall', '-Wextra', '-Werror', '-fexceptions', '-DNDEBUG', '-std=c++11', '-x', 'c++', '-isystem', '/usr/inc
lude', '-isystem', '/usr/local/include', '-isystem', '/usr/lib/clang/5.0.1/include', '-isystem', '/usr/include/c++/7.2.1
', '-isystem', '/usr/include/c++/7.2.1/x86_64-pc-linux-gnu', '-isystem', '/usr/include/c++/7.2.1/backward', '-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1', '-isystem', '/Applicati
ons/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include', '-resource-dir=/usr/share/vim/vimfile
s/bundle/Data/YouCompleteMe/third_party/ycmd/ycmd/../clang_includes', '-fspell-checking']
-- Server running at: http://127.0.0.1:36297
-- Server process ID: 19442
-- Server logfiles:
-- /tmp/ycmd_36297_stdout_nYWpxX.log
-- /tmp/ycmd_36297_stderr_9R2Q7f.log
You are getting these errors because the order of your -isystem flags is wrong: /usr/include/c++/7.2.1 must be included before /usr/include. Try the following .ycm_extra_conf.py file:
def FlagsForFile( filename ):
return { 'flags': [
'-Wall',
'-Wextra',
'-Werror',
'-std=c++11',
'-x', 'c++',
'-isystem', '/usr/include/c++/7.2.1',
'-isystem', '/usr/include/c++/7.2.1/x86_64-pc-linux-gnu',
'-isystem', '/usr/include/c++/7.2.1/backward',
'-isystem', '/usr/local/include',
'-isystem', '/usr/include',
] }
@micbou
thx very very much!!!!!
i dont know there is a squence for these include files!
Why the order matters? I also have a similar problem and fixed reorder it include path.
Why the order matters? I also have a similar problem and fixed reorder it include path.
i also want to know
Because the STL is a special snowflake and is allowed to do weird stuff within its headers. There's a lot of preprocessor based redefining of symbols. For example C++11 redefined C's islower and turned it into an inline function, but, *I think * only if a C header already defined islower as a macro, probably assuming that, if your C doesn't support islower C++ won't be able to support it either.
I have the same problem, but with headers optional and variant. YCM doesn't highlight the includes as missing, but will claim that no template named 'optional' in namespace 'std'. My include flags:
Flags: ['-x', 'c++', '-Wall', '-Werror', '--std=c++17', '-isystem', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1', '-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include', '-isystem', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include', '-isystem', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
platform/Developer/SDKs/MacOSX10.14.sdk/usr/include', '-isystem', '/usr/local/include', '-I/usr/local/opt/e2fsprogs/include', '-resource-dir=/Users/anton/.local/share/vim/bundle/YouCompleteMe/third_party/ycmd/clang_includes', '-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1', '-isystem', '/usr/local/include', '-isystem', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/cla
ng/10.0.0/include', '-isystem', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include', '-isystem', '/usr/include', '-iframework', '/System/Library/Frameworks', '-iframework', '/Library/Frameworks', '-isystem', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include', '-fspell-checking']
The first -isystem directive contains the directory (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1) that has the optional header (with no extension).
@AFakeman The flag is -std=c++17, not --std=c++17.
@bstaletic Thanks, fixed. Still doesn't really work.
@micbou Thanks a lot. It also helped me fix a problem "RuntimeError: No completions found; errors in the file?" . It happened when I tried to enter a dot to trigger the completion of member variables.
Most helpful comment
You are getting these errors because the order of your
-isystemflags is wrong:/usr/include/c++/7.2.1must be included before/usr/include. Try the following.ycm_extra_conf.pyfile: