我的用的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包啦!