Since the Sublime text 3 build 3083 update, short-cuts for building and running single file C++ programs have changed. If you loved the old shortcuts (cmd+b to compile and cmd+shift+b to run), you can restore them by adding these custom key bindings.
{
"keys": ["super+b"],
"command": "build",
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.c++" }
],
"args": {
"build_system": "Packages/C++/C++.sublime-build",
"variant": "Build"
}
},
{
"keys": ["super+shift+b"],
"command": "build",
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.c++" }
],
"args": {
"build_system": "Packages/C++/C++.sublime-build",
"variant": "Run"
}
},
{
"keys": ["super+b"],
"command": "build",
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.java" }
],
"args": {
"build_system": "Packages/Java/Java.sublime-build",
"variant": "Build"
}
},
{
"keys": ["super+shift+b"],
"command": "build",
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.java" }
],
"args": {
"build_system": "Packages/Java/Java.sublime-build",
"variant": "Run"
}
}
Hope this helps :)
EDIT: The previous script I mentioned had a bug : The short-cut keys were executing c++ build command even for java source code. I have resolved that bug using 'context'. 'context' helps link multiple build_systems / commands with same short-cuts. So this should do the trick. And any undefined build_systems here would be executing default behaviour for the short-cuts :)
Well can you help me to solve my problem of running C++ in Sublime text 2? It shows an error of this kind.
g++: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found compilation terminated.
I downloaded MinGW and then added the bin address to the environment variables in advanced system settings in Windows 8.1.. Can you help??
In your 'Packages' folder you should have the 'C++/C++.sublime-build' file for the script to work. Please let me know if you have it.
Yes.. In
preferences->Browse packages
right?? I have it !!Then the problem seems to be in your C++.sublime-build. Try this in your C++.sublime-build.
And do i just add this to the existing code in it or replace the whole code??
modify your existing code with above parameters. "path" is the path to your 'bin' folder in MinGW.
how and where to enter input?
You can add a command to run your compiled program from XTerm, or whatever terminal depending on your OS
Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) [Finished in 0.1s with exit code 1] [cmd: ['g++', '-std=c++0x', '/Users/OptiMaze/Documents/ut.cpp', '-o', '/Users/OptiMaze/Documents/ut']] [dir: /Users/OptiMaze/Documents] [path: /Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/OptiMaze/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
i am getting this message while running my c++ code. Can anyone help me with this?
How to comment a block of C++ code in sublime text 3?