Sublime Forum

Windows 10 build system open cmd window

#1

I want to open cmd window every time i build my file.c (ctrl+B or F7)
i tried to paste this code to my new build system but it doesn’t work
“variants”:
{
“name”: “Run”,
“cmd”: “main.exe”
}
code “cmd”: “main.exe” gives me output in sublime window build result, but I don’t want it because i want to use scanf in my programms.

0 Likes

#2
0 Likes

#3

Do you know how can i look at the C Single File build system and edit it?

0 Likes

#4

https://packagecontrol.io/packages/PackageResourceViewer is an easy way.

1 Like

#5

I found this command but it shows errors:
“variants”: [

    {   
    	"name": "Run",
        "cmd": ["start", "cmd", "/k", "\"${file_path}/${file_base_name}\""],
        "working_dir" : "$file_path",
        "shell": true,
        
    }
]

Error: shell_cmd or cmd is required,
What is wrong here?

0 Likes

#7

I am not sure since I am not really familiar with build system. But your variants seems using neither console exec nor terminus.

I am going to sleep and hopefully others may help you. Here’s my C Single File.sublime-build with Console Exec if that ever helps.

0 Likes

#8

i have something like this:
{
“cmd” : [“gcc”, “$file_name”, “-o”, “${file_base_name}.exe”],
“file_regex”: “^(…[^:]):([0-9]+):?([0-9]+)?:? (.)$”,
“shell”:true,
“working_dir” : “$file_path”,
“variants”: [

    {   
        "cmd": ["start", "cmd", "/k", "\"${file_path}\\\\${file_base_name}\""],
        "shell": true,
        "name": "Run",
        "target": "console_exec",
    }
]

}
now it is working correctly

0 Likes

#10

File name with spaces not working

> {
> 	"shell_cmd": "gcc \"${file}\" -o \"${file_path}/${file_base_name}\"",
> 	"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
> 	
> 	"shell":true,
> 	"working_dir" : "$file_path",
> 	"variants": [
> 
>         {   
>         "cmd": ["start", "cmd", "/k", "gcc \"${file}\" && ${file_path}\\\\${file_base_name}"],
>         "shell": true,
>         "name": "Run",
>         "target": "console_exec",
>         }
>     ]
> }

I have added \" to ${file}, but still it shows errors:
gcc: error: “C:…\exc: Invalid argument
gcc: error: 1.c”: Invalid argument
gcc: fatal error: no input files
compilation terminated.

0 Likes

#11

Unless you have a really compelling reason to want to open an external console window every time, my recommendation would be to use Terminus for this as it’s a lot easier. You can use View Package File to open the C Single File.sublime-build file, copy and paste it into a new buffer, and then add two lines to it to get things working.

[edit]
This may not work as expected if you’ve used PackageResourceViewer and overridden the built in build system. In that case you’ll need to remove or rename your override first; otherwise no matter what you do you’re only going to see your customization and nothing else.
[/edit]

An example of the process can be found in the following video (example uses Python, but just swap it for the build file you actually want to modify, the same things apply regardless).

0 Likes

#12

I’ve answered this over on Stackoverflow.

0 Likes