You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04 LTS下使用GCC-12编译C++代码时提示找不到cc1plus的问题求助

Ubuntu 22.04 LTS下使用GCC-12编译C++代码时提示找不到cc1plus的问题求助

大家好,我在Ubuntu 22.04 LTS上用GCC-12编译C++代码时碰到了麻烦——我的机器上同时装了GCC 11和12两个版本,现在编译一段简单的代码时出现了错误,想请大家帮忙看看。

我要编译的代码如下:

#include <iostream>

using namespace std;

int main() {
    cout << "Hello, World!" << endl;
}

VS Code里的tasks.json配置是这样的:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "Build with GCC 11",
            "command": "/usr/bin/gcc-11",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "-L/usr/lib/x86_64-linux-gnu/libstdc++.so.6",
                "-lstdc++",
                "-std=c++17",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

但当我执行Build with GCC 12的编译任务时,弹出了如下错误:

Executing task: Build with GCC 12

Starting build... /usr/bin/gcc-12 -fdiagnostics-color=always -g
-L/usr/lib/x86_64-linux-gnu/libstdc++.so.6 -lstdc++ -std=c++20 /home/pratham/Downloads/C++/hello.cpp -o
/home/pratham/Downloads/C++/hello

gcc-12: fatal error: cannot execute ‘cc1plus’: execvp: No such file or
directory compilation terminated.

Build finished with error(s).

The terminal process failed to launch (exit code: -1).

Terminal will be reused by tasks, press any key to close it.

有没有大佬能帮我分析下问题出在哪,该怎么解决呀?

备注:内容来源于stack exchange,提问作者anon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 07:42:59