Unable find printf.c on Ubuntu 16.04

别来无恙 提交于 2021-02-05 11:13:18

问题


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:

Unable to open 'printf.c': File not found (file:///build/glibc-Cl5G7W/glibc-2.23/stdio-common/printf.c).

How can I fix the problem?

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"
    }
}

回答1:


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.

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.



来源:https://stackoverflow.com/questions/52650371/unable-find-printf-c-on-ubuntu-16-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!