After installing VS Code Version: 1.85.2 (Universal), the ";" symbol in the line of arguments(args) is interpreted into the terminal as "';'". Consequently, after running c++ file the terminal can't run the commands.
The tasks.json:
{
"tasks":
[
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"${file}",
"${workspaceFolder}/src/glad.c",
"-I/${workspaceFolder}/include",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-L/${workspaceFolder}/include",
"-lglfw.3",
";",
"install_name_tool",
"-change",
"@rpath/libglfw.3.dylib",
"${workspaceFolder}/lib/libglfw.3.dylib",
"${workspaceFolder}/src/main"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
},
],
"version": "2.0.0"
}
The terminal after running the c++ file:
/usr/bin/g++ -fdiagnostics-color=always /Users/user/Desktop/OpenGLProjects/EBO/src/main.cpp /Users/user/Desktop/OpenGLProjects/EBO/src/glad.c -I//Users/user/Desktop/OpenGLProjects/EBO/include -o /Users/user/Desktop/OpenGLProjects/EBO/src/main -L//Users/user/Desktop/OpenGLProjects/EBO/include -lglfw.3 ';' install_name_tool -change @rpath/libglfw.3.dylib /Users/user/Desktop/OpenGLProjects/EBO/lib/libglfw.3.dylib /Users/user/Desktop/OpenGLProjects/EBO/src/main
clang: error: unknown argument: '-change' clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated] clang: error: no such file or directory: 'install_name_tool' clang: error: no such file or directory: '@rpath/libglfw.3.dylib'
As you can see, the ";" symbol is put into these grave accents.
ChatGPT suggested me to rewrite my tasks.json file:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"${file}",
"${workspaceFolder}/src/glad.c",
"-I/${workspaceFolder}/include",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-L/${workspaceFolder}/include",
"-lglfw.3",
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
},
{
"label": "Change install_name_tool",
"type": "shell",
"command": "install_name_tool",
"args": [
"-change",
"@rpath/libglfw.3.dylib",
"${workspaceFolder}/lib/libglfw.3.dylib",
"${workspaceFolder}/src/main"
],
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task to change install_name_tool"
}
],
"version": "2.0.0"
}
But it didn't work.
Would appreciate for the help.
Because that's shell syntax, and VS Code tasks are not generalized shell command executors (though there is a shell
task type). If you want to run multiple commands in sequence, use the compound tasks feature.