[技巧] NOI LINUX 中不用自己手打的Sublime配置环境

一般我们测试代码时,需要开 O2 ,而 Sublime 中的 C++ Single File 是没有 O2 的,为此,我们需要手打环境;

其实是不用的;

第一步,打开“文件”中的“其它位置”中的“计算机”;

image

image

第二步,在上面的搜索栏中搜索“Sublime”;

image

打开图中高亮的,找到如下图中高亮的并打开,复制;

image

发现会有如下的几行;

{
	"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
	"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
	"working_dir": "${file_path}",
	"selector": "source.c++",

	"variants":
	[
		{
			"name": "Run",
			"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
		}
	]
}

在倒数第四行中“&&”前加入-std=c++14 -O2 -Wall,即可完成;

如果想开大栈,在 g++ \"${file}\" 前加 ulimit -s 81920000(大约80MB)即可;

{
	"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
	"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
	"working_dir": "${file_path}",
	"selector": "source.c++",

	"variants":
	[
		{
			"name": "Run",
			"shell_cmd": "ulimit -s 81920000 g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++14 -O2 -Wall && \"${file_path}/${file_base_name}\""
		}
	]
}

最后,在 Sublime 中建立一个新的文件即可;

具体如下:

找到 Sublime 中的 tools ,选择里面的 Build system 中的 New build system

image

在里面将如上的代码复制进去并保存即可;

image

大功告成!

posted @   Peppa_Even_Pig  阅读(152)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示