简体   繁体   中英

unable to setup C++ environment with sublime text and mingw

I am trying to set up sublime text with mingw. I have add the path as C:\\mingw\\bin I have add the build system with the following code:

{
    "cmd" : "g++ $file_name -o ${file_base_name} && ${file_base_name}",
    "selector" : "source.c",
    "shell": true,
    "working_dir" : "$file_path"
}

However I got a compiler error when running any code:

The syntax of the command is incorrect.
[Finished in 0.1s with exit code 1]
[cmd: g++  -o  && ]
[dir: C:\Program Files\Sublime Text 3]
[path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\MinGW\bin;C:\Users\Quaxie\AppData\Local\Microsoft\WindowsApps;]

I have been googling for the past 4 hours and tried with multiple build codes and non of the worked. I cant really figure out which part went wrong, any help would be greatly appreciated.

You need to change "cmd" to "shell_cmd" and put curly braces around file_name and file_path . Also, adding a "file_regex" key and value will assist you in locating any errors in the build.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM