Search code examples
c++sublimetext3sublimelinter

SublimeLinter clang - Can't find basic headers


I've recently installed Sublime Text 3 and I'm trying to get the SublimeLinter to work for C++. I've installed the "SublimeLinter-contrib-clang" linter with the Package Control, and the linter does activate. However, my issue is that the linter gives an error for every basic header, ie #include <iostream> in a basic Hello World program.

What I've tried to do:

  • Installed clang, g++, and latest libstdc libraries
  • Compiled and ran the program using clang from the terminal with clang++ -v <name_of_file>
  • Tried and failed to manually include c++ library directory in the settings

The last one seems to be the best choice, but it seems I don't understand how Sublime settings work at all. Here is my User settings file: (color scheme and ignored packages lines were already there)

{
    "color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
    "ignored_packages":
    [
        "Vintage"
    ],
    "SublimeLinter-contrib-clang": {
        "include_dirs": "/usr/include/c++"
    }
}

I've tried various formats (under "linters"->"clang", "clang", etc), but none of it works. Additionally, I'm not even sure this method will work.

Thanks~

(Using Ubuntu 14.04)

Edit: My current user settings file:

{
    "color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
    "font_size": 11,
    "ignored_packages":
    [
        "Vintage"
    ],
    "linters": {
        "clang": {
                "extra_flags": [],
                "include_dirs": [
                    "/usr/include/c++/4.8.2"
                ]
            }
    }
}

Solution

  • This was happening because the plugin used clang with the -cc1 flag, which could be described as turning it into internal mode which omits options (i.e. platform specific location settings).

    outlined in the llvm docs

    The problem has since been fixed.