stdio.h頭文件報錯和更新/etc/apt/source源

我的用的Ubuntu 16系統
我的C程序:

#include<stdio.h>
int main(){
        printf("Hello Linux!!!\n");
        return 0;
}

遇到這樣的報錯:

root@ubuntu:/hello# gcc hello.c -o hello
hello.c:1:9: fatal error: stdio.h: No such file or directory
 #include<stdio.h>
         ^~~~~~~~~
compilation terminated.

原因:Ubuntu中沒有配置一個 libc6-dev的包
解決辦法 : 運行 apt-get install libc6-dev (注意所有的安裝、更新都要獲取管理者權限,或者直接前面加上"sudo",下同)

然而~~~~
又遇到這樣的問題:

root@ubuntu:~# apt-get install libc6-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libc6-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libc6-dev' has no installation candidate

原因:是/etc/apt/source.list中的源已經比較舊了,要進行更新
解決辦法:運行 apt-get -y update

顯示這樣子:
在這裏插入圖片描在這裏插入圖片描述述
表示已經更新列表完畢,現在可以愉快的安裝libc6-dev包啦!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章