在 Ubuntu 16.04 上无法找到 printf.c [英] Unable find printf.c on Ubuntu 16.04

查看:42
本文介绍了在 Ubuntu 16.04 上无法找到 printf.c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I recently switched to the Ubuntu 16.04. I am using vscode for as IDE on Ubuntu. I configure other languages, but I could not do it for C/C++. I created c_cpp_properties.json, launch.json & tasks.json. When I started to compile the any given code, It gives an error when the fit functions like printf or malloc. The Error message:

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

Unable to open 'printf.c': File not found (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"
    }
}

推荐答案

不幸的是,Debian 和 Ubuntu 没有将源代码作为调试包的一部分提供.据我所知,也没有计划将源代码作为 dbgsym 包 的一部分发布.

Debian and Ubuntu do not ship sources as part of the debugging packages unfortunately. As far I can tell, there is no plan to ship sources as part of dbgsym packages, either.

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

In contrast, Fedora and its downstream distributions have extensive infrastructure to prepare usable source files for debugging. It is not entirely trivial to do this because it requires rewriting file paths in the DWARF data, from the build tree location to the installation location. But it can be really helpful for debugging and gives a nice free software flavor to the entire distribution.

这篇关于在 Ubuntu 16.04 上无法找到 printf.c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆