sublimeClang 是github上面的开源项目,可用于C/C++的自动补全
github:https://github.com/quarnster/SublimeClang
配置sublime text 2和sublimeCLang C/C++环境的步骤:
1.下载解压到/opt目录中,创建软链接
tar -jxvf Sublime Text 2.0.1.tar.bz2 -C /opt/ //解压到/opt ln -s /opt/sublime text 2/sublime_text /usr/bin/sublime2 //建立软链接
2.下载sublimeClang,解压到指定目录(百度云上有一个 http://pan.baidu.com/s/1qWOgyS0)
unzip sublimeClang.zip -d ~/.config/sublimt-text-2/Packages
3.安装clang,将libclang复制到指定目录
yum install epel-releas //安装 第三方源库 yum install clang //安装clang ldconfig -p | grep libclang //查找libclang的路径 cp /usr/lib64/llvm/libclang.so ~/.config/Sublime-text-2/Packages/SublimeClang /internals/libclang.so
4.ctypes不能导入,可查看https://github.com/quarnster/SublimeClang
curl -kL http://xrl.us/pythonbrewinstall | bash source "$HOME/.pythonbrew/etc/bashrc" pythonbrew install --configure="--enable-unicode=ucs4" 2.6 ln -s $HOME/.pythonbrew/pythons/Python-2.6/lib/python2.6/ <your Sublime Text 2 folder>/lib/python2.6
5.编译
cd sublimeClang/src mkdir build cmake .. make
6.终端输入 sublime2 打开编辑器,测试自动补全功能
7.按上述安装好后,能自动补全,但是发现nullptr 位没有声明,需要设置以下
按下ctrl + shift + p快捷键,在弹出的输入框中输入 sublimeclang settings ,然后选择带User那一行,在打开的文件中输入如下信息:
(根据自己下路径适当修改)
{
"show_output_panel": false,
"dont_prepend_clang_includes": true,
"inhibit_sublime_completions": false,
"options":
[
"-std=gnu++11",
"-isystem", "/usr/include",
"-isystem", "/usr/include/c++/*",
"-isystem", "/usr/include/c++/4.8",
"-isystem", "/usr/include/c++/4.8/*",
"-isystem", "/usr/include/boost",
"-isystem", "/usr/include/boost/**",
"-isystem", "/usr/lib/gcc/x86_64-linux-gnu/4.8/include",
"-isystem", "/usr/lib/gcc/x86_64-linux-gnu/4.8/include/*"
]
}