Sublime Text 3,GCC构建系统问题

时间:2017-11-01 20:50:15

标签: c gcc sublimetext3

在构建工作的“.c”代码文件时,我遇到了构建错误,需要构建菜单图标(构建系统GCC)

当我导航:工具 - >构建(选择GCC作为构建系统)

[Finished in 0.5s]

但如果我导航:工具 - >命令调色板 - >建立:GCC

***Expected working output***

按照上面这个心爱的视觉,我会导航:工具 - >构建(选择GCC作为构建系统),OR工具 - >命令调色板 - >建立:GCC -RUN

// Put this file here:
// "C:\Users\[User Name]\AppData\Roaming\Sublime Text 3\Packages\User"
// Use "Ctrl+B" to Build and "Crtl+Shift+B" to Run the project.
// OR use "Tools -> Build System -> New Build System..." and put the code there.
{
    "cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe"],

    // Doesn't work, sublime text 3, Windows 8.1    
    // "cmd" : ["gcc $file_name -o ${file_base_name}"],

    "selector" : "source.c",
    "shell": true,
    "working_dir" : "$file_path",

    // You could add path to your gcc compiler this and don't add path to your "PATH environment variable"
    // "path" : "C:\\MinGW\\bin"

    "variants" : [

        { "name": "Run",
          "cmd" : ["${file_base_name}.exe"]
        }
    ]
}

这是我的GCC.sublime-build文件,我怀疑这是导致问题的文件。

a = open('filename.txt','r')
b = a.readlines()
a.close()
c = len(b)
d = list(zip(*(e.split() for e in b)))

self.r11 = []
self.r21 = []
self.yr = []
self.mn = []
self.dy = []
self.f = d[0]
self.g = d[1]
self.h = d[2]
self.i = d[3]
self.j = d[4]
for n in range(2, c):
    nn = int(self.f[n])
    if nn > mm:
        self.yr.append(self.f[n])
        self.mn.append(self.g[n])
        self.dy.append(self.h[n])
        self.r11.append(self.i[n])
        self.r12.append(self.j[n])

虽然问题可能在这里,但我非常担心它可能也在其他地方,因为我一直在努力实施库。 第二个问题是为什么我的“路径:”变量这么长,是否不必要地长?其中许多不需要崇高的正确吗?

1 个答案:

答案 0 :(得分:0)

这将使您能够在sublime以及命令提示符下编译和运行c ++程序

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

"variants":
[   // to run in the sublime text console
    {
        "name": "Run",
        "shell_cmd":"\"${file_path}/${file_base_name}\""
    },
    // to run in the Windows command line
    {
        "name": "Run in cmd",

        "shell_cmd":   "start cmd /k  $file_base_name "

    }
]}