sublime配置c++环境

1,安装编译器g++

 下载地址:https://sourceforge.net/projects/mingw-w64/

 装好mingw之后将bin/目录添加到path环境变量中去,然后再cmd中输入以下代码,测试是否装好

g++

如果出现下图所示情况,表明安装成功

sublime配置c++环境

2,在sublime中配置环境

tools  > Build System > New Builed System 

将其中的内容改成如下,并保存为CPP.sublime-build文件

{
    //"shell_cmd": "make",
    "cmd": ["g++","-Wall", "${file}", "-o", "${file_path}/${file_base_name}"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++,source.cpp",
    "encoding": "cp936",
    "variants":
        [
            {"name": "Run",
            "cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "cmd", "/c", 
            "${file_path}/${file_base_name}"]
            },
            {"name": "RunInCommand",
            "cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"]
            },
            {"name": "RunInShell",
            "shell_cmd": " start cmd /c ""${file_path}/${file_base_name}"&pause" "
            }
        ]
}

然后Preferences > Key Bindings中输入以下内容

{"keys": ["f5"], "command": "build", "args": {"variant": "Run"}},
{ "keys": ["f6"], "command": "build", "args": {"variant": "RunInCommand"} },

ctrl+n建立新文件,ctrl+s保存为.cpp文件,tools > Build System > CPP

写好之后f5或者f6编译运行程序

sublime配置c++环境

3,有用的插件

clang, EasyClangComplete、SublimeCodeIntel

 

原文链接: https://www.cnblogs.com/54hys/p/10513666.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    sublime配置c++环境

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/291258

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月15日 下午1:32
下一篇 2023年2月15日 下午1:35

相关推荐