Does anyone knows why vs-code can't find c++ compiler. I have used vc-code for several months without any problems, but suddenly without any clear reason it can't find the compiler anymore!! does somebody here can figure out what could be causing this.
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command":"g++ $(pkg-config --cflags --libs opencv gl glew sdl2)",
"args": ["-g", "${workspaceFolder}/*.cpp", "-lstdc++fs", "-pthread"],
"group":{
"kind": "build",
"isDefault": true
}
}
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}",
"/usr/include/c++/6.3.0",
"/usr/include/c++/6",
"/usr/include/x86_64-linux-gnu/c++/6",
"/usr/include/c++/6/backward",
"/usr/lib/gcc/x86_64-linux-gnu/6/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"/usr/bin"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceFolder}",
"/usr/include/c++/6.3.0",
"/usr/include/c++/6",
"/usr/include/x86_64-linux-gnu/c++/6",
"/usr/include/c++/6/backward",
"/usr/lib/gcc/x86_64-linux-gnu/6/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"/usr/bin"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 3
}
output
/bin/bash: g++ $(pkg-config --cflags --libs opencv gl glew sdl2): command not found
NOTE: I still can use g++ to compile files in the integrated terminal in vs-code, but it cannot be recognized by tasks.json !!!
i don't think that this could relate to this problem, cause i have been using it like this for long time with no problem. and in general during the compilation all of this parts gonna be clipped together.
You updated your command so your statement is not true more. Namely you added command substitution $(...) that is not processed in Visual Studio Code and passed as is in once command to bash. The right solution is below:
"tasks": [
{
"label": "echo",
"type": "process",
"command":"/bin/bash",
"args": [ "-c", "g++", "$(pkg-config --cflags --libs opencv gl glew sdl2)", "-g", "${workspaceFolder}/*.cpp", "-lstdc++fs", "-pthread"],
"group":{
"kind": "build",
"isDefault": true
}
}
]
Or bit shorter
"tasks": [
{
"label": "echo",
"type": "process",
"command":"/bin/bash",
"args": [ "-c", "g++ $(pkg-config --cflags --libs opencv gl glew sdl2) -g ${workspaceFolder}/*.cpp -lstdc++fs -pthread"],
"group":{
"kind": "build",
"isDefault": true
}
}
]
Related
I'm using an old 2015 macbook air ver 10.13.6
vs code Version: 1.74.0 (Universal)
extensions : C/C++ , Code Runner
I'm learning c++ and here's the basic code I'm trying to test to see if my vscode is good to go
I'm doing this in a C++Projects folder and the file name helloworld.cpp
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
when I run my file it says Build finished successfully.
but afterwards it says unable to start debugging
here are the other files I have that pop up
launch.json :
"configurations": [
{
"name": "C/C++: clang++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ build active file"
}
]
tasks.json :
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
Please help I've been searching for answers on this and can't seem to find any. Much appreciated!
checked to see if clang was installed. yes
changed the task and launch files
Install the VS Code extension, 'code lldb', with following config:
{
"name": "clang++ - Build and debug active file",
"type": "lldb",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "C/C++: clang++ build active file" //<-- your build task name
}
I'm trying to add a build task to build the current file, just a simple "make path/to/file.o". I'm using vscode on windows 10 over a remote SSH connection to linux.
However, if I use ${relativeFileDirname} it converts the path separators to windows format. Eg...
${fileDirname}=/home/me/git/project/data/source
${relativeFileDirname}=data\source
I've read about explorer.copyRelativePathSeparator. Can that be applied to the build task in tasks.json? Or is there another way?
This is the build task...
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/make",
"args": [
"${relativeFileDirname}/${fileBasenameNoExtension}.o"
],
"options": {
"cwd": "/home/me/git/project"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/gcc",
"presentation": {
"clear": true
}
}
Thanks.
There is an extension for Visual Studio Code for this purpose that, after many failed attempts to use string substitution with bash built-ins and sed, was the only working solution for me:
"customOptions": "--workdir /home/user/${command:extension.commandvariable.file.relativeFileDirnamePosix}",
I compiled v8 on Linux Min 20.2 using VsCode.
My build tasks.json task looks like this
"tasks": [
{
"label": "gm x64.debug all",
"type": "shell",
"command": "tools/dev/gm.py x64.debug all",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "dedicated",
"clear": true
},
"problemMatcher": {
"fileLocation": [
"relative",
"${workspaceFolder}out/x64.debug/"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
launch.json config
{
"name": "(gdb) launch hello_world",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/x64.debug/v8_hello_world",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
Breakpoints working well also callstack is available but there is no local variables.
I use extension "C/C++ (by Microsoft)".
How I can enable them?
(V8 developer here.)
Inspecting local variables should work by default. You could try running the compiled binary in GDB to see if something is missing from the binaries, or it's an issue with VSCode's integrated debugger or its configuration.
One thing to keep in mind is that tools/dev/gm.py will not overwrite existing build settings. If you e.g. manually put symbol_level = 1 or v8_optimized_debug = true (two examples for settings that will break your debugging experience) into out/x64.debug/args.gn, then gm.py will maintain these settings, assuming that you put them there on purpose. To get back to the defaults, you can rm -rf out/x64.debug. You can also look up the default settings in gm.py's source.
I have the C/C++ ms-vscode.cpptools extension installed (and the Code Runner).
This is my task.json
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-g",
"-Wall",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/gcc"
}
]
Note the -Wall option in the args part.
When I compile and run the code the warnings don't show up in my terminal, the errors only.
Am I missing something?
Solved it was the configuration of code runner to be edited as well.
"code-runner.executorMap": {
...
"c": "cd $dir && gcc -Wall $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
...
Now if I build via VSCode and via code runner I have my warnings displayed.
While running SublimeREPL: SBT for opened folder, I have the exact same problem as in The similar question asked before (OSError(2, 'No such file or directory')).
Unofrtunately, the solution provided there did not help much.
Would anybody be kind enough to give some clues as to what might still be wrong here?
I'm currently running Ubuntu 12.04.
My Main.sublime-menu config is as follows:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"caption": "Scala",
"id": "Scala",
"children":[
{"command": "repl_open",
"caption": "scala REPL",
"id": "repl_scala",
"mnemonic": "s",
"args": {
"type": "subprocess",
"encoding": "utf8",
"external_id": "scala",
"cmd": {"linux": ["scala"],
"osx": ["scala"],
"windows": ["scala.bat", "-i"]},
"soft_quit": "\nexit\n",
"cwd": "$file_path",
"cmd_postfix": "\n",
"extend_env": {"osx": {"EMACS": "1", "PATH": "{PATH}:/home/helluin/apps/sbt/bin"},
"linux": {"EMACS": "1", "PATH": "{PATH}:/home/helluin/apps/sbt/bin/"},
"windows": {"EMACS": "1"}},
"suppress_echo": false,
"syntax": "Packages/Scala/Scala.tmLanguage"
}
},
{"command": "repl_open",
"caption": "SBT for opened folder",
"id": "repl_sbt",
"mnemonic": "b",
"args": {
"type": "subprocess",
"encoding": "utf8",
"external_id": "scala",
"cmd": {"linux": ["sbt"],
"osx": ["sbt"],
"windows": ["sbt"]},
"soft_quit": "\nexit\n",
"cwd": "$folder",
"cmd_postfix": "\n",
"extend_env": {"osx": {"EMACS": "1", "PATH": "{PATH}:/usr/bin"},
"linux": {"EMACS": "1", "PATH": "{PATH}:/usr/bin"},
"windows": {"EMACS": "1"}},
"suppress_echo": false,
"syntax": "Packages/Scala/Scala.tmLanguage"
}
}
]}
]
}]
}
]
Also, the scala and sbt system paths are defined thusly
λ → which scala
/usr/bin/scala
λ → which sbt
/home/helluin/apps/sbt/bin/sbt
You have your paths mixed up. The "caption": "scala REPL" menu item has scala as its command, but the extended PATH is /home/helluin/apps/sbt/bin. The "caption": "SBT for opened folder" item has sbt as its command, yet the extended PATH is /usr/bin. You should switch them.
Alternatively, for the Scala REPL, make the first line of the command:
"cmd": {"linux": ["/usr/bin/scala"],
(although /usr/bin should already be in the system PATH). For the sbt REPL, make the first line of the command:
"cmd": {"linux": ["/home/helluin/apps/sbt/bin/sbt"],
and then you don't need to worry about extending that particular environment variable.