1

I have created a C++14.sublime-build file from tools>Build System>New Build System. The code that I placed inside is:

{
 
 "cmd":["bash", "-c", "g++ -std=c++14 -Wall '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"],
 "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
 "working_dir": "${file_path}",
 "selector": "source.c, source.c++",
 "variants":
 [
   {
     "name": "Run",
     "cmd":["bash", "-c", "g++ -std=c++14 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
   }
 ]
}

But whenever I select C++14 from tools> Build System, an error occurs saying /bin/bash: g++: command not found

Note: The program compiles and works properly when I select C++ Single File in tools>Build System.

Please help!

zrrbite
  • 1,180
  • 10
  • 22
rgv
  • 61
  • 10
  • "g++: command not found" - So install the compiler, gcc/g++ . Sublime is just a text editor. It's not your compiler. – Jesper Juhl Sep 25 '20 at 17:29
  • @JesperJuhl the OP states right in the question that when using another C++ build system, *"The program compiles and works properly"*. So, gcc/g++ is clearly already installed and functional... – MattDMo Sep 25 '20 at 19:10
  • is there some reason you're trying to invoke bash to get it to run the command instead of just using `shell_cmd`, which does the same thing? On Linux, `shell_cmd` does what you're doing; on MacOS it also provides `-l` to make sure that the environment is set up correctly. So if you're on MacOS, that might solve your issue – OdatNurd Sep 25 '20 at 20:37
  • As an added note, your `Run` variant is not appropriately named (which is harmless but confusing). Both builds will always compile and run, the only difference is that the top level build also includes `-Wall`. All else being equal, you may be better off creating a build based on the default and not from random advice on the internet, which is frequently incorrect or misleading in my experience helping people with build problems. – OdatNurd Sep 25 '20 at 20:38
  • @OdatNurd I am using windows. How to fix the problem? – rgv Sep 26 '20 at 16:46
  • Are you using WSL for this, or just MinGW? – OdatNurd Sep 26 '20 at 19:50
  • @OdatNurd just MinGW – rgv Sep 28 '20 at 20:13
  • It's probably complaining about you trying to use `bash`; as I mentioned above, is there some reason you're trying to use `bash` here? – OdatNurd Sep 29 '20 at 21:08

0 Answers0