O
O
Oleksandr172012-06-30 22:57:43
Programming
Oleksandr17, 2012-06-30 22:57:43

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}'"]
    }
  ]
  
}

When compiling, it sees [Decode error - output not UTF-8], and I would like the compiled program to open in a window, like in compilers ( Code::Blocks ).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
klimenkov, 2013-12-29
@Oleksandr17

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"]
    }
  ]
}

O
Oleksandr17, 2012-07-01
@Oleksandr17

And how to make the compiled program run in a window ... like other compilers (Code::Blocks|DevCpp) ...

R
Ramires, 2012-07-01
@Ramires

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 question

Ask a Question

731 491 924 answers to any question