'How to use c++ with terminus in sublime text 4

I recently started learning c++ and want to implement it into sublime text with input from the build panel (the default c++ build system doesn't allow for input).

My current build system looks like this:

{
"target": "terminus_exec",
"cancel": {"kill": true},
"focus": true,

"shell_cmd": "g++ -o $file_base_name $file && $file_path/$file_base_name.exe",
}

When I run the build, I get this error:

cc1plus.exe: fatal error: strings\file.cpp: No such file or directory                                                                                                    
compilation terminated

This is the closest I've gotten to getting it working. I haven't written build systems before so if there is anything I should know it would be greatly appreciated.



Solution 1:[1]

Thanks to OrdaNurd, I got it working. My final code looks like this:

{
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
"focus": true,

"working_dir": "%file_path",
"shell_cmd": "g++ -o \"$file_path/$file_base_name\" \"$file\" && \"$file_path/$file_base_name\"",
}

The quotations are needed for files/paths with spaces and I added the working directory because it was needed on my python version (it probably doesn't need it here).

For a while, the executable was being created in my user folder which was quite confusing, but this creates it in the directory the file is located (I think).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Widdop4