Bro!
The most important advice is that you are advised not to use spaces in the directory or file names.
Is your multiple sources files architecture like this:
fitBodyBootCamp
|
|_.vscode
| |__c_cpp_properties.json
| |__launch.json
| |__settings.json
| |__tasks.json
|__test.cpp
|__test.h
|__testImp.cpp
If so, This is a project with multiple sources files under the same folder.
Your "tasks.json
" should be:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Compile With clang++",
//"command": "clang++",/usr/bin/clang++
"command": "/usr/bin/clang++",
"args": [
"-std=c++11",
"-stdlib=libc++",
// My project fitBodyBootCamp were under
// /Users/marryme/VSCode/CppProject/fitBodyBootCamp
// So ${workspcaeFolder} also were
// /Users/marryme/VSCode/CppProject/fitBodyBootCamp
// all the *.cpp files were under
// /Users/marryme/VSCode/CppProject/fitBodyBootCamp
"${workspaceFolder}/*.cpp", // Have changed
"-o",
// Thanks those chiense website bloggers!
// 1.mac vscode compile c++ multi-directory code demo
// https://blog.csdn.net/fangfengzhen115/article/details/121496770?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-4.pc_relevant_default&spm=1001.2101.3001.4242.3&utm_relevant_index=7
// 2.Compile and debug c++ multi-folder project under VSCode (non-makefile)
// https://blog.csdn.net/BaiRuichang/article/details/106463035
// I also put the main.o under my current workspace directory
// This after "-o" is the target file test.o or test.out or test
"${workspaceFolder}/${fileBasenameNoExtension}", // Have changed
"-I",
// This after "-I" if the include files directory
"${workspaceFolder}", // Have changed
"-Wall",
"-g"
],
"options": {
// "cwd" is the source files directory
"cwd": "${workspaceFolder}" // Have changed
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
If you use gcc/g++
, just change the clang/clang++
to those.
If this line code needs to change or function, I add the comment
"// Have changed
". Just notices that line code! Please!
"tasks.json
": You know, that's "tasks.json
"!!! NOT "task.json
".
More about "launch.json
" or "c_cpp_properties.json
" or
"settings.json
",
please make reference to Multiple CXX Same Folder Manually VSCode(mac)
from GitHub Gist,
Or, make reference to Multiple CXX Same Folder Manually VSCode(mac) from Github.
Or your multiple sources files architecture like this:
fitBody
|
|_.vscode
| |__c_cpp_properties.json
| |__launch.json
| |__settings.json
| |__tasks.json
|__build
|__inc
| |__fitbody.h
|__src
|__fitbody.cpp
|__main.cpp
If so, That is separated multiple sources files.
Your "tasks.json
" is just like this:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Compile With clang++",
// Just use clang compiler
//"command": "clang++",/usr/bin/clang++
"command": "/usr/bin/clang++", // Have changed
"args": [
"-std=c++11",
"-stdlib=libc++",
// My project fitBodyBootCamp were under
// /Users/marryme/VSCode/CppProject/fitBody
// So ${workspcaeFolder} also were
// /Users/marryme/VSCode/CppProject/fitBody
// all the *.cpp files were under
// /Users/marryme/VSCode/CppProject/fitBody/src
// this is the source files diretory
"${workspaceFolder}/src/*.cpp", // Have changed
"-o",
// Thanks those chiense website bloggers!
// 1.mac vscode compile c++ multi-directory code demo
// https://blog.csdn.net/fangfengzhen115/article/details/121496770?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-4.pc_relevant_default&spm=1001.2101.3001.4242.3&utm_relevant_index=7
// 2.Compile and debug c++ multi-folder project under VSCode (non-makefile)
// https://blog.csdn.net/BaiRuichang/article/details/106463035
// I also put the main.o under my build folder directory ../build
// This after "-o" is the target file main.o or main.out or main
"${workspaceFolder}/build/${fileBasenameNoExtension}", // Have changed
"-I",
// This is include directory.
"${workspaceFolder}/inc", // Have changed
"-Wall",
"-g"
],
"options": {
// "cwd" is the source files directory
"cwd": "${workspaceFolder}/src" // Have changed
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
More about "launch.json
" or "c_cpp_properties.json
" or
"settings.json
",
please make reference to Separated Multiple CXX Manually VScode(mac) from GitHub Gist.
Or, make reference to Separated Multiple CXX Manually VScode(mac) from GitHub.
END!