In C++ in VSCode I wrote a program and when I wanted to configure it I created and configured a tasks.json and c_cpp_properties.json and then command-shift-b d it and that built it (created the binary file) and then in the integrated terminal I had to ./(thebinaryfile) for it to run. What code do I have to put in tasks.json OR c_cpp_properties in order for it to not only build, but also run, when I hit Control-shift+b? From which JSON file do I alter the command for execution and what code should I add/replace? I have read all the MS provided docs and Googled but still find myself confused.
My c_cpp_properties.json file is c_cpp_properties.json - Pastebin.com.
Code:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/local/include", "/Users/me/Downloads/SFML-2.5.1-macos-clang/include"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
My tasks.json file is { "version": "2.0.0", "tasks": [ { "label": "ech - Pastebin.com
Code:
{
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo Hello"
},
{
"type": "shell",
"label": "clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-I/Users/me/Downloads/SFML-2.5.1-macos-clang/include",
"-L/Users/me/Downloads/SFML-2.5.1-macos-clang/lib",
"-lsfml-graphics",
"-lsfml-window",
"-lsfml-system",
"-lsfml-audio"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
},
{
"type": "shell",
"label": "clang build active file",
"command": "/usr/bin/clang++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
}
}
]
}
My code is #include <SFML/Graphics.hpp> int main() { sf::RenderWindow window(sf::V - Pastebin.com .
Code:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}