• sublime text 3 c++配置(编译+运行)


    之前在网上找了很多配置教程都没成功,要么只能编译,要么只能运行编译好后的exe,没办法一键运行。

    方法:

    • 操作方式: 点击**工具,再选编译系统,再选新建编译系统**
    • 然后,把下面的代码,全部复制,并且,替换掉原来的那些地方。
    • 之后保存就好了。 比如说,我保存的文件名就是CPP.sublime-build

    运行代码(改编自https://blog.csdn.net/a19990412/article/details/82658981,编译是可以的,但是运行有点问题,已修改):

    { 
        "cmd": ["g++", "${file}", "-std=c++11", "-o", "${file_path}\\${file_base_name}", "&", "start", "cmd", "/c", "${file_base_name}.exe & echo. & pause"],
        "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}",
        "selector": "source.c, source.c++", "shell": true,
        "encoding":"cp936", 
    
        "variants":
        [
            {
                "name" : "Build Only",
                "cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\${file_base_name}"]
            },
            {
                "name" : "Run Only",
                "cmd" : ["start", "cmd", "/c", "${file_path}\\${file_base_name} & echo. & pause"]
            },
            {
                "name" : "Pipe Build and Run",
                "cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\${file_base_name}","&","${file_path}\\${file_base_name}", "<","${file_path}\\in",">","${file_path}\\out"]
            },
            {
                "name" : "Pipe Run Only",
                "cmd" : ["${file_base_name}", "<","in",">","out"]
            },
            {
                "name" : "Project Build & Run",
                "cmd" : ["g++", "${file_path}\\*.cpp", "-std=c++11", "-o", "${file_path}\\project", "&", "start", "cmd", "/c", "${file_path}\\project & echo. & pause"]
            },
            {
                "name" : "Project Build Only",
                "cmd" : ["g++", "${file_path}\\*.cpp", "-std=c++11", "-o", "${file_path}\\project"]
            },
            {
                "name" : "Project Run Only",
                "cmd" : ["start", "cmd", "/c", "${file_path}\\project & echo. & pause"]
            }
        ]
    }

    然后重启软件,在工具选项里选择 用……编译 

    选择你刚刚的文件名即可

  • 相关阅读:
    什么是TCP, UDP, HTTP, HTTPS协议?
    Django 自定义分页器
    PHP7.3安装event扩展
    深入浅出 PHP SPL(PHP 标准库)(转)
    Centos7安装redis5.0.7
    useradd命令详解(转)
    centos7.5下安装rabbitmq服务端以及php扩展
    php-fpm启动,重启,退出
    深度好文:PHP写时拷贝与垃圾回收机制(转)
    非对称加密openssl协议在php7实践
  • 原文地址:https://www.cnblogs.com/Ctrl-cCtrl-v/p/15060462.html
Copyright © 2020-2023  润新知