2

I installed Ubuntu yesterday, so I don't know what many of the commands mean. I am just learning as they come. I installed Sublime Text 3 editor and tried to compile and run a program using a tutorial based on Ubuntu 16.04. The compilation was successful, but it shows some sort of error like this and the opened running terminal doesn't do anything.

IMAGE 1

So what I did was to change the build system: in line 12 I removed '-e' and added '--':

IMAGE 2

IMAGE 3

Now the error is not shown in the compile status, but the terminal is showing another error.

IMAGE 4

I think I need to make some additional changes to the Build System.

Here's the code I used for Build System:

{
 "cmd": ["g++", "$file", "-o", "${file_path}/${file_base_name}"],
 "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
 "working_dir": "${file_path}",
 "selector": "source.c, source.c++, source.cxx, source.cpp",
 "variants":
 [
    {
        "name": "Run",
        "shell": true,
        "cmd": ["gnome-terminal -e 'bash -c 
        \"${file_path}/${file_base_name};echo;echo;  echo Press ENTER 
        to continue; read line;exit; exec bash\"'"]
   }
 ]
}

1 Answer 1

3

In Sublime Text 3 build systems cmd has a different syntax: you should write each argument of command in different quotes, like this:

"cmd": ["gnome-terminal", "-e", "'bash -e ...'"]

It's easier to use shell_cmd.

"shell_cmd": "gnome-terminal -- bash -c 'Your command here'"

For example, this will execute your compiled program and wait for any key to be pressed:

"shell_cmd": "gnome-terminal -- bash -c '${file_path}/${file_base_name}; read -sn 1'"
2
  • Thanks :) it actually helped...now my terminal automatically opens with the code compiled and without error...but I still have to type ./a.out to run the program...is there a way to skip that too?
    – Aman Kumar
    Dec 7, 2019 at 6:40
  • It means that you compile your file manually with g++ ${file_name}. And default output filename for g++ is a.out. You can replace your run command with ${file_path}/a.out, or compile file with default build system Dec 7, 2019 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .