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] Groovy Project Compile Error: java.lang.NoClassDefFoundError: org/apache/tools/ant/util/ReaderInputStream
- [Solved] Android Studio Compile Error: Invalid main APK outputs : EarlySyncBuildOutput
- Android Studio Error: String index out of range 0 [How to Solve]
- [Solved] error adding symbols: File in wrong format collect2: error: ld returned 1 exit status
- [Solved] Error C1189: #error: Please use the /MD switch for _AFXDLL builds
- [Solved] Execution failed for task ‘:app:checkDebugAarMetadata‘
- Error lnk2038: detected “_ ITERATOR_ DEBUG_ Mismatched ‘level’ value of ‘0’
- [Solved] C++ Compile: error LNK2019: unresolved external “XX“
- How to Solve Error: “initializer element is not constant”
- [GO] The entry file under the main package in golang calls other go file functions and appears undefined
- [Solved] Mac Cmake Complie openmp Error: fatal error: ‘omp.h‘ file not found
- How to Solve “/usr/bin/ld: skipping incompatible”
- [Solved] Unity Package Error: Failed running D:\Program Files\Unity2018.4.1\Editor\Data\il2cpp/build/il2cpp.exe
- Error in loading latex project compilation [How to Solve]
- Error: # error PCL requires C++ 14 or above
- [Solved] Compile Error: AAPT: error: resource android:attr/lStar not found
- Kotlin gets the ID automatically error [How to Solve]
- Error occurred during initialization of VM Could not reserve enough space for 1572864KB object heap
- [Solved] Manifest merger failed with multiple errors, see logs