解决sublime text 3编译c++的问题

第一步请参照博客:https://blog.csdn.net/lhshu2008/article/details/17582949

实际是增加了一个编译系统。

然后就基本没问题了。

但是当编译源文件名称包含空格,例如:'Ctext space'时将无法编译。

此时重新修改 C.sublime-build 文件内容如下:

自己改变第一个 path 的值。

{
	"path": "C:/MinGW/bin",
	"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -Wall -Wextra && start cmd /c \"\"${file_path}/${file_base_name}\" & pause \"",
	"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
	"working_dir": "${file_path}",
	"selector": "source.c, source.c++",

	"variants":
	[
		{
			"name": "build",
			"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -Wall -Wextra"
		},
		{
			"name": "Run",
			"shell_cmd": "start cmd /c \"\"${file_path}/${file_base_name}\" & pause \""
		}

	]
}

此时按提前设好的快捷键可以运行已编译好的 .exe 文件。

但修改后运行, .exe 文件不变。

此时先用 ctrl+shift+B 选择 C++ Single File。

用 ctrl+B 进行编译,然后用快捷键运行。

但一定不要选用 C++ Single File - Run。

因为一但有输入操作,将卡在底边的小框中。

posted @ 2020-02-07 13:49  敲可耐的螺旋藻  阅读(397)  评论(0编辑  收藏  举报