Has*_*uad 1 c++ linux gnu dwarf gcc11
我在我的机器(linux 20.04)上使用自制软件安装了 gcc 11。而且它没有在 vscode 上运行,如图所示
as:无法识别的选项“--gdwarf-5”
不知道是不是路径问题。因为当我安装brew时它告诉我
Warning: /home/linuxbrew/.linuxbrew/bin/ is not in your PATH.
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,它建议使用这三个命令
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /home/hasib/.profile
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/hasib/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
Run Code Online (Sandbox Code Playgroud)
所以,我做了那些。我不知道这是否搞砸了路径。我对Linux有点陌生,所以很困惑。只是想在 vs 上运行 gcc-11
这是我的tasks.json 文件:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "Build with GCC 11.3.0",
"command": "/home/linuxbrew/.linuxbrew/bin/g++-11",
"args": [
"-fdiagnostics-color=always",
"-g",
"-std=c++20",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /home/linuxbrew/.linuxbrew/bin/g++-11"
},
{
"type": "cppbuild",
"label": "C/C++: g++-10 build active file",
"command": "/usr/bin/g++-10",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /usr/bin/g++-10"
}
],
"version": "2.0.0"
}
Run Code Online (Sandbox Code Playgroud)
启动.json:
{
"version": "0.2.0",
"configurations": []
}
Run Code Online (Sandbox Code Playgroud)
输出gcc-11 --version:
gcc-11 (Homebrew GCC 11.3.0) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Run Code Online (Sandbox Code Playgroud)
输出gdb --version:
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Run Code Online (Sandbox Code Playgroud)
as(GNU 汇编器)是 binutils 软件包的一部分。您需要安装as支持该--gdwarf-5标志的最新版本的 binutils 并确保它是gcc-11.
您可以as通过运行来检查 $PATH 中的是否支持该标志
as --help | grep gdwarf
Run Code Online (Sandbox Code Playgroud)
如果是,则返回包含以下行:
--gdwarf-<N> generate DWARF<N> debugging information. 2 <= <N> <= 5
Run Code Online (Sandbox Code Playgroud)
如果没有返回,请尝试通过 linuxbrew 安装最新版本的 binutils(如果还没有,请重新启动桌面会话以确保所有终端和 vscode 都获得 $PATH 等的更新)