Answer the question
In order to leave comments, you need to log in
Is Sublime text 2 a C++ compiler?
Help setting up a C++ compiler for Sublime text 2 , I've tried a few things but it didn't work...
Here is my .sublime-build file.
{
"cmd": ["g++", "$file", "-Wall", "-o", "$file_base_name", "&&", "$file_base_name"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell":true,
"path": "C:/Program Files/Sublime Text 2/bin",
"encoding": "UTF-8",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
Answer the question
In order to leave comments, you need to log in
As far as I understand, the whole problem is in the && symbol. Just write where Run is, a command that will simply run what is compiled. I did this and everything works:
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["${file_path}/${file_base_name}.exe"]
}
]
}
And how to make the compiled program run in a window ... like other compilers (Code::Blocks|DevCpp) ...
Look at the command the editor is trying to execute.
Troubleshooting
After pressing F7, you can see the command that was actually run by taking a look in the Console (via View/Console). Taken from here .
If the command is correct, then the matter is in the language settings. An example of the same error on the editor's forum.
Try to make a simple config like this or this and gradually increase the options you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question