title: How to setup VS Code for Building, Running and Debugging simple C++ files in OSX?
body: <p>The closest similar answer I found for it is <a href="https://stackoverflow.com/questions/44377981/vs-code-setup-for-c">here</a></p>
  
  <p>But that doesn't contain an answer to my question. I also went through the <a href="https://code.visualstudio.com/docs/languages/cpp" rel="nofollow noreferrer">docs</a> for trying to have C++ support to VSCode. I didn't find OSX specific settings and I am not well versed with such configurations. Could someone please help
  ?</p>
  
  <p><strong>Update:</strong> </p>
  
  <p>Adding the contents of tasks.json, launch.json, c_cpp_properties.json, and terminal output for more clarity:</p>
  
  <p>tasks.json:</p>
  
  <pre><code>{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build &amp; debug file",
      "type": "shell",
      "command": "g++",
      "args": [
        "-g",
        "-o",
        "${fileBasenameNoExtension}",
        "${file}"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "build &amp; run file",
      "type": "shell",
      "command": "g++",
      "args": [
        "-o",
        "${fileBasenameNoExtension}",
        "${file}"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": []
    }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>launch.json:</p>
  
  <pre><code>{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
      {
          "name": "(lldb) Launch",
          "type": "cppdbg",
          "request": "launch",
          "program": "${workspaceFolder}/test",
          "args": [],
          "stopAtEntry": false,
          "cwd": "${workspaceFolder}",
          "environment": [],
          "externalConsole": true,
          "MIMode": "lldb"
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>c_cpp_properties.json:</p>
  
  <pre><code>{
  "configurations": [
      {
          "name": "Mac",
          "includePath": [
              "${workspaceFolder}/**",
              "/usr/local/Cellar/gcc/7.1.0/include/c++/7.1.0",
              "/usr/include/c++/4.2.1"
          ],
          "defines": [],
          "macFrameworkPath": [
              "/System/Library/Frameworks",
              "/Library/Frameworks"
          ],
          "compilerPath": "/usr/bin/clang",
          "cStandard": "c11",
          "cppStandard": "c++17",
          "intelliSenseMode": "clang-x64"
      }
  ],
  "version": 4 }
  </code></pre>
  
  <p>Current problem I am facing with this configuration is that I get the following error when I try: Terminal-> Run Build Task-> build &amp; debug file:</p>
  
  <pre><code>    ld: warning: ignoring file /Users/xyz/Workspace/VSCode/.vscode/tasks.json, file was built for unsupported file format ( 0x7B 0x0A 0x20 0x20 0x20 0x20 0x22 0x76 0x65 0x72 0x73 0x69 0x6F 0x6E 0x22 0x3A ) which is not the architecture being linked (x86_64): /Users/xyz/Workspace/VSCode/.vscode/tasks.json
  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)
  The terminal process terminated with exit code: 1
  </code></pre>