Pregunta

{
    "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",
            "working_dir": "${file_path}",
            "cmd": ["${file_path}/${file_base_name} < ${file_path}/${file_base_name}.input"]
        }
    ]
}

This is the sublime-text 2 custom build file that I have created to compile the code and run the code using an input file. But, it always returns the following error.

[Errno 2] No such file or directory
[cmd:  [u'/home/p-kar/codebase/codechef/CDR2014/test < /home/p-kar/codebase/codechef/CDR2014/test.input']]
[dir:  /home/p-kar/codebase/codechef/CDR2014]
[path: /home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/p-kar/bin]
[Finished]

Where am I going wrong??

¿Fue útil?

Solución

In your example, your run variant isn't compiling anything before running it. You need to edit your build file to something like:

"variants":
    [
        {
            "name": "Run",
            "cmd": ["bash", "-c", "/usr/local/bin/gcc '${file}' -Wall -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
        }
    ]
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top