Mac Vscode C++ Customize Header File Error: linker command failed

Project scenario:

Customized a swap header file and failed to compile

Cause analysis:

Tip: C_cpp_properties.json and tasks.json only the current file is compiled by default. If only main.cpp is selected, it will only compile this one file.


Tip: modify C_cpp_properties.json and tasks.json configuration file, which compiles the source files in the specified directory.

c_cpp_properties.json Modify:

“includePath”: [
"configurations": [
            "name": "Mac",
            "includePath": [
            "defines": [],
            "macFrameworkPath": [
            "compilerPath": "/usr/bin/clang++",
            "cStandard": "c11",
            "cppStandard": "c++98",
            "intelliSenseMode": "macos-clang-x64"
    "version": 4

Modify tasks.json

	"version": "2.0.0",
	"tasks": [
      "type": "cppbuild",
      "label": "C/C++: clang++ files",
      "command": "/usr/bin/clang++",
      "args": [
      "options": {
        "cwd": "${fileDirname}"
      "problemMatcher": [
      "group": {
        "kind": "build",
        "isDefault": true
      "detail": "Compiler: /usr/bin/clang++"

After saving, return to the project folder, click Shift + Command + B in the blank space to compile, and then execute the compiled program ./main in terminal.

Read More: