在Ubuntu下安装Sublim Text3后发现无法输入中文,按照此链接的方法解决后。然后用下列代码配置C++的编译系统:
{
"cmd":["g++","${file}","-o","${file_path}/${file_base_name}"], "file_regex":"^(..[^:]*):([0-9]+):?([0-9]+)?:?(.*)$", "working_dir":"${file_path}", "selector":"source.c,source.c++", "variants": [ { "name":"Run", "cmd":["gnome-terminal","-x","bash","-c","g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}' ; re ad -n1 -p 'press any key to continue.'"] } ]
}
在配置完C++开发环境后编译发现报错。
错误如下:
(gnome-terminal:22242): Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
[Finished in 0.2s with exit code -5]
[cmd: ['gnome-terminal', '-x', 'bash', '-c', "g++ '/root/Code/test.cpp' -o '/root/Code/test' && '/root/Code/test' ; read -n1 -p 'press any key to continue.'"]]
[dir: /root/Code]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
由于我们安装的支持中文的库使用的是GTK2.0的图形库,而gnome-terminal使用的是GTK3.0的库
在尝试将支持中文的库编译为基于GTK3.0的程序后再打开sublime程序直接崩溃。。
不得已,只能使用xterm代替gnome-terminal。将C++编译系统代码改为
{ "cmd": "g++ "${file}" -o "${file_path}/${file_base_name}"", "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++", "variants": [ { "name": "Run", "cmd":["xterm","-fa","文泉驿等宽微米黑","-e","g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}' ; read -n1 -p 'press any key to continue.'"] } ] }
成功!