【问题标题】:Unable find printf.c on Ubuntu 16.04在 Ubuntu 16.04 上找不到 printf.c
【发布时间】:2019-03-10 01:28:20
【问题描述】:

我最近切换到Ubuntu 16.04。我在 Ubuntu 上使用 vscode 作为 IDE。我配置了其他语言,但我无法为C/C++ 配置。我创建了c_cpp_properties.json, launch.json & tasks.json。当我开始编译任何给定的代码时,当拟合函数如printfmalloc 时会出错。 错误信息:

无法打开“printf.c”:找不到文件 (file:///build/glibc-Cl5G7W/glibc-2.23/stdio-common/printf.c)。

我该如何解决这个问题?

launch.json

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/test.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "build"
    }
]
}

tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "gcc",
        "args": [
            "-g",
            "pointer_revision.c",
            "-o",
            "test.exe"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}

c_cpp_properties.json

{
      "configurations": {
        "name": "Linux",
        "includePath": [
            "${workspaceFolder}",
            "/usr/include/x86_64-linux-gnu/5/include",
            "/usr/local/include",
            "/usr/include/x86_64-linux-gnu/5/include-fixed",
            "/usr/include/x86_64-linux-gnu",
            "/usr/include"
        ],
        "defines": [],
        "intelliSenseMode": "clang-x64",
        "browse": {
            "path": [
               "${workspaceFolder}",
                "/usr/include/x86_64-linux-gnu/5/include",
                "/usr/local/include",
                "/usr/include/x86_64-linux-gnu/5/include-fixed",
                "/usr/include/x86_64-linux-gnu",
                "/usr/include"
            ],
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
        },
        "compilerPath": "/usr/bin/gcc"
    }
}

【问题讨论】:

  • 这是一个特性,而不是一个错误。字面上地!他们说这是“设计”在这里:github.com/Microsoft/vscode-cpptools/issues/1123
  • “像 printf 或 malloc 这样的 fit 函数会报错。”,这是什么意思?
  • 有一个拼写错误。不合身,会被打。

标签: c linux ubuntu visual-studio-code vscode-settings


【解决方案1】:

很遗憾,Debian 和 Ubuntu 并未将源代码作为调试包的一部分提供。据我所知,也没有计划将资源作为dbgsym packages 的一部分发送。

相比之下,Fedora 及其下游发行版拥有广泛的基础设施来准备可用的源文件以进行调试。这样做并不完全是微不足道的,因为它需要重写 DWARF 数据中的文件路径,从构建树位置到安装位置。但它对调试非常有帮助,并为整个发行版提供了很好的免费软件风格。

【讨论】:

  • 我从 Windows 10 切换过来。我不想再使用 Windows。对我来说这是一个全新的 Linux 环境
  • 啊。如果您想通过源代码进入系统库,我认为 Ubuntu 不是正确的选择,恐怕。选择此发行版当然还有其他原因,但源代码调试不是其中之一。
  • 我将 Ubuntu 16.04 切换到 Manjaro KDE。我现在很开心。它与 VScode 完美配合。我可以毫无问题地调试。我用过的最好的发行版
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-27
  • 1970-01-01
  • 1970-01-01
  • 2018-04-30
  • 2020-05-18
相关资源
最近更新 更多