Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ccls error not finding 'string.h' on MacOS #716

Closed
ggilles opened this issue Nov 5, 2020 · 1 comment
Closed

ccls error not finding 'string.h' on MacOS #716

ggilles opened this issue Nov 5, 2020 · 1 comment

Comments

@ggilles
Copy link

ggilles commented Nov 5, 2020

Hello,

I have been fighting with this issue for a while, and despite following the documentation, including the fixes for MacOS/Catalina described here (#191 (comment)) and there (#512 (comment)).

I compiled ccls with:

cmake -G Ninja -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/Users/gilles/dev-tools/clang+llvm-11.0.0-x86_64-apple-darwin
ninja -C Release

And here is the VSCode configuration I have:

    "ccls.launch.command": "/Users/gilles/dev-tools/ccls/Release/ccls",
    "ccls.clang.extraArgs": [
        "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
        "-isysroot", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
    ],
    "ccls.clang.resourceDir": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0",
    "ccls.cache.directory": "/Users/gilles/.ccls-cache/",
    "ccls.misc.compilationDatabaseDirectory": "_buildDebug",
    "ccls.index.onChange": true,

According to that comment #191 (comment)
This should be correct:

ccls git:(1fec76c8) $ grep CMAKE_CXX_COMPILER Release/CMakeCache.txt
CMAKE_CXX_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
//ADVANCED property for variable: CMAKE_CXX_COMPILER
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1

ccls git:(1fec76c8) /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -print-resource-dir
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0

Now using this configuration on a very simple project, I still get a "string.h" not found error:

CMakeLists.txt

project(ccls-error)

add_executable(cclserror main.cc)

main.cc

#include <string>
int main(void)
{
    return 0;
}

The problem is I still get error about 'string.h' not being found. See this screenshot:

VSCode screenshot

Here is the full project for reference:
ccls-error.zip

Any ideas how to fix this?

@ggilles
Copy link
Author

ggilles commented Nov 7, 2020

I eventually found a way to solve the problem: use llvm-10.0 instead of llvm-11.0

Here is how I compiled ccls:

$ cmake -GNinja -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/Users/gilles/dev-tools/clang+llvm-10.0.0-x86_64-apple-darwin && cmake --build Release

And the relevant part of my VSCode config:

    "ccls.launch.command": "/Users/gilles/dev-tools/ccls/Release/ccls",
    "ccls.cache.directory": "/Users/gilles/.ccls-cache/",
    "ccls.clang.extraArgs": [
        "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1"
    ],
    "ccls.misc.compilationDatabaseDirectory": "_buildDebug",
    "ccls.index.onChange": true,

And now everything works correctly

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant