最近,我从 VS Code 转向了 Sublime 文本编辑器。在 VS 代码中,我使用 Microsoft 的 C/C++ 扩展来进行 C++ 自动完成。
我完成了https://github.com/niosus/EasyClangComplete中给出的步骤。
我可以执行前 2 步,但第 3 步即配置编译器标志和包含文件夹让我感到困惑。我怎样才能成功安装这个插件?
最近,我从 VS Code 转向了 Sublime 文本编辑器。在 VS 代码中,我使用 Microsoft 的 C/C++ 扩展来进行 C++ 自动完成。
我完成了https://github.com/niosus/EasyClangComplete中给出的步骤。
我可以执行前 2 步,但第 3 步即配置编译器标志和包含文件夹让我感到困惑。我怎样才能成功安装这个插件?
Step1 : 要安装 EasyClangComplete,首先你需要有 Package Control。然后按以下
CTRL+Shift+P for Windows
CMD+Shift+P for MacOS
现在搜索包控制:安装包并按回车键。然后搜索 EasyClangComplete 并安装它。
Step2 : 需要安装 Clang
Ubuntu : sudo apt-get install clang
MacOS : By default installed. You are all set!
Windows : install the latest release from clang website.
检查是否安装成功
clang --version
第 3 步:配置编译器标志并包含文件夹。
对于这一步,您只需在项目根文件夹中创建 2 个空文件。
CMakeLists.txt
compile_commands.json
现在,重新启动 sublime 文本编辑器和自动完成功能将成功运行。
转到包设置 > EasyClangComplete > 设置。现在在文件“EasyClangComplete.sublime-settings”中添加以下代码
{
"common_flags" : [
// some example includes
"-I/usr/include",
"-I$project_path/src",
// this is needed to include the correct headers for clang
"-I/usr/lib/clang/$clang_version/include",
// For simple projects, you can add a folder where your current file is
"-I$file_path",
],
}