Search code examples
c++sublimetext3

Using Sublime Text 3 for C++ giving permission denied?


I have a problem with my Sublime Text 3 running C++ in the console.

I pointed my PATH in my computer settings to the directory of my compiler for C++ and created a custom build script to run it in Sublime Text 3. For the most part it runs my code but after a couple of runs it gives me an error:

C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/5.1.0/../../../../mingw32/bin/ld.exe: cannot open output file C:\Users\obier\Desktop\C++ Projects\HelloWorld\SublimeNewHelloWorld/HelloWorld.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
[Finished in 0.4s]

I'm not sure what is going on.

Here is the custom Sublime Text 3 custom-build code I am using to compile it:

{
"shell_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",
        "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
    }
]
}

If any of ya'll have any good user friendly programs ya'll can suggest that might work better than using Sublime Text 3 than feel free to leave them.


Solution

  • Check the shell command you used, it is depending on the OS.

    Also check the file permissions because the file may not executable.

    Also see "Can't build even a simple program in Sublime Text 3".