Project scenario:
Customized a swap header file and failed to compile
Cause analysis:
Tip:
C_cpp_properties.json
andtasks.json
only the current file is compiled by default. If only main.cpp is selected, it will only compile this one file.
Solution:
Tip: modify
C_cpp_properties.json
andtasks.json
configuration file, which compiles the source files in the specified directory.
c_cpp_properties.json
Modify:
“includePath”: [ “${workspaceFolder}/**”
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang++",
"cStandard": "c11",
"cppStandard": "c++98",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
Modify tasks.json
“-g”, “${fileDirname}/*.cpp”
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ files",
"command": "/usr/bin/clang++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${fileDirname}/*.cpp",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"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:
- VSCode Unable to find custom header file directory: fatal error: no such file or directory
- [Solved] Latex&VScode Error: I found no bibdata command//command//citation—while reading file*.aux
- [Solved] VScode Run C++ File Error: fatal error:opencv2\core.hpp:No such file or diretory
- [Solved] Mac M1 Brew install Error: Command failed with exit 128:git
- [Solved] C# Access Mongodb Database Error: command find failed: Command find requires authentication
- ApplicationContext.xml file header error Referenced file contains errors
- [Solved] VScode Error: PS D:\vscode> cd “d:\vscode\“ ; if ($?) { g++ tempCodeRunnerFile.cpp -o tempCodeRunn
- Mac installation tree command error solution
- [Solved] PCH Warning: header stop not at file scope
- [Solved] MAC Nginx Error: ginx.pid“ failed (2: No such file or directory)
- C++ Primer Program in VsCode error: no match for call to ‘(std::__cxx11::string…)
- How to Solve error: command ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe‘ failed
- Mac error: SH: Vue cli service: command not found
- Mac Error: sh: vue-cli-service: command not found
- [Solved] Linux Start jar Error: nohup: failed to run command ‘java‘: No such file or directory
- [Solved] OpenCV error: #error “This header with legacy C API declarations has been removed from OpenCV.
- [Solved] Vscode Connect SSH Error: Error Running the contributed command ‘_workbench.downloadResource
- [Solved] fatal error: bits/libc-header-start.h: No such file or directory
- [Solved] VsCode + gfortran Compiler Error: error: ld returned 1 exit status