关于使用apt-get install build-essential和make C源文件的问题

时间:2018-01-19 12:55:47

标签: c linux

我要在Ubuntu 17.10上编写C代码,当我打算用make命令编译时,终端消息是:

dophia@ubuntu:~/Downloads/datalab-handout$ make world
The program 'make' can be found in the following packages:
 * make
 * make-guile
Try: sudo apt install <selected package>

我用Google搜索并获得了解决方案

sudo apt-get update
sudo apt-get install build-essential

然后我得到了:

Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following additional packages will be installed:
  dpkg-dev fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl    
  libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4    
  libatomic1 libc-dev-bin libc6 libc6-dbg libc6-dev libcilkrts5    
  libfakeroot libgcc-7-dev libitm1 liblsan0 libmpx2 libquadmath0    
  libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev make manpages-dev
Suggested packages:
  debian-keyring g++-multilib g++-7-multilib gcc-7-doc    
  libstdc++6-7-dbg gcc-multilib autoconf automake libtool flex bison   
  gcc-doc gcc-7-multilib gcc-7-locales libgcc1-dbg libgomp1-dbg   
  libitm1-dbg libatomic1-dbg libasan4-dbg liblsan0-dbg libtsan0-dbg   
  libubsan0-dbg libcilkrts5-dbg libmpx2-dbg libquadmath0-dbg 
  glibc-doc libstdc++-7-doc make-doc   
The following NEW packages will be installed:
  build-essential dpkg-dev fakeroot g++ g++-7 gcc gcc-7   
  libalgorithm-diff-perl libalgorithm-diff-xs-perl    
  libalgorithm-merge-perl libasan4 libatomic1 libc-dev-bin libc6-dev   
  libcilkrts5 libfakeroot libgcc-7-dev libitm1 liblsan0 libmpx2   
  libquadmath0 libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev make   
  manpages-dev  
The following packages will be upgraded:
  libc6 libc6-dbg
2 upgraded, 27 newly installed, 0 to remove and 39 not upgraded.
Need to get 34.4 MB of archives.
After this operation, 116 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6-dbg amd64 2.26-0ubuntu2.1 [4,997 kB]
**Get:2 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6 amd64 2.26-0ubuntu2.1 [2,780 kB]
Err:2 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6 amd64 2.26-0ubuntu2.1
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:b90d28f35eedf6fd218a90bf4c0634f5d60686e2f2ed38c4e283f581fbe8eef2
   - SHA1:54c460b9ca8746481342047236c6c3ceaec877a4 [weak]
   - MD5Sum:3069cbb5207a71f297b741c025de42ca [weak]
   - Filesize:2779898 [weak]
  Hashes of received file:
   - SHA256:0ed5fbdf0f3dcce4e428dd34b063043abcc8e56fed895fd58cb813fece65beb1
   - SHA1:f9b0e80321aa9b4a29fc7414072374366ecd5068 [weak]
   - MD5Sum:9a27e8f5f78d7c271cdc771f26a45e70 [weak]
   - Filesize:69466 [weak]
  Last modification reported: Wed, 17 Jan 2018 10:09:06 +0000**
Get:2 http://security.ubuntu.com/ubuntu artful-security/main amd64 libc6 amd64 2.26-0ubuntu2.1 [2,780 kB]
blah blah...
Get:29 http://us.archive.ubuntu.com/ubuntu artful/main amd64 manpages-dev all 4.13-3 [2,202 kB]
Fetched 34.4 MB in 4min 28s (128 kB/s)                                
Preconfiguring packages ...
(Reading database ... 126030 files and directories currently installed.)
Preparing to unpack .../libc6-dbg_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc6-dbg:amd64 (2.26-0ubuntu2.1) over (2.26-0ubuntu2) ...
Preparing to unpack .../libc6_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc6:amd64 (2.26-0ubuntu2.1) over (2.26-0ubuntu2) ...
Setting up libc6:amd64 (2.26-0ubuntu2.1) ...
Selecting previously unselected package libc-dev-bin.
(Reading database ... 126030 files and directories currently installed.)
Preparing to unpack .../00-libc-dev-bin_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc-dev-bin (2.26-0ubuntu2.1) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../01-linux-libc-dev_4.13.0-25.29_amd64.deb ...
Unpacking linux-libc-dev:amd64 (4.13.0-25.29) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../02-libc6-dev_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc6-dev:amd64 (2.26-0ubuntu2.1) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../03-libitm1_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libitm1:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../04-libatomic1_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libatomic1:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libasan4:amd64.
Preparing to unpack .../05-libasan4_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libasan4:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../06-liblsan0_7.2.0-8ubuntu3_amd64.deb ...
Unpacking liblsan0:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../07-libtsan0_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libtsan0:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libubsan0:amd64.
Preparing to unpack .../08-libubsan0_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libubsan0:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libcilkrts5:amd64.
Preparing to unpack .../09-libcilkrts5_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libcilkrts5:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libmpx2:amd64.
Preparing to unpack .../10-libmpx2_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libmpx2:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../11-libquadmath0_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libquadmath0:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libgcc-7-dev:amd64.
Preparing to unpack .../12-libgcc-7-dev_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libgcc-7-dev:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package gcc-7.
Preparing to unpack .../13-gcc-7_7.2.0-8ubuntu3_amd64.deb ...
Unpacking gcc-7 (7.2.0-8ubuntu3) ...
Selecting previously unselected package gcc.
Preparing to unpack .../14-gcc_4%3a7.2.0-1ubuntu1_amd64.deb ...
Unpacking gcc (4:7.2.0-1ubuntu1) ...
Selecting previously unselected package libstdc++-7-dev:amd64.
Preparing to unpack .../15-libstdc++-7-dev_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libstdc++-7-dev:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package g++-7.
Preparing to unpack .../16-g++-7_7.2.0-8ubuntu3_amd64.deb ...
Unpacking g++-7 (7.2.0-8ubuntu3) ...
Selecting previously unselected package g++.
Preparing to unpack .../17-g++_4%3a7.2.0-1ubuntu1_amd64.deb ...
Unpacking g++ (4:7.2.0-1ubuntu1) ...
Selecting previously unselected package make.
Preparing to unpack .../18-make_4.1-9.1_amd64.deb ...
Unpacking make (4.1-9.1) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../19-dpkg-dev_1.18.24ubuntu1_all.deb ...
Unpacking dpkg-dev (1.18.24ubuntu1) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../20-build-essential_12.4ubuntu1_amd64.deb ...
Unpacking build-essential (12.4ubuntu1) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../21-libfakeroot_1.21-1ubuntu2_amd64.deb ...
Unpacking libfakeroot:amd64 (1.21-1ubuntu2) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../22-fakeroot_1.21-1ubuntu2_amd64.deb ...
Unpacking fakeroot (1.21-1ubuntu2) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../23-libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../24-libalgorithm-diff-xs-perl_0.04-4build3_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-4build3) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../25-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../26-manpages-dev_4.13-3_all.deb ...
Unpacking manpages-dev (4.13-3) ...
Setting up libquadmath0:amd64 (7.2.0-8ubuntu3) ...
Setting up libatomic1:amd64 (7.2.0-8ubuntu3) ...
Setting up make (4.1-9.1) ...
Setting up libc6-dbg:amd64 (2.26-0ubuntu2.1) ...
Setting up libasan4:amd64 (7.2.0-8ubuntu3) ...
Setting up libcilkrts5:amd64 (7.2.0-8ubuntu3) ...
Setting up libubsan0:amd64 (7.2.0-8ubuntu3) ...
Setting up libtsan0:amd64 (7.2.0-8ubuntu3) ...
Setting up linux-libc-dev:amd64 (4.13.0-25.29) ...
Setting up liblsan0:amd64 (7.2.0-8ubuntu3) ...
Setting up libmpx2:amd64 (7.2.0-8ubuntu3) ...
Setting up dpkg-dev (1.18.24ubuntu1) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...
Setting up libfakeroot:amd64 (1.21-1ubuntu2) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libc-dev-bin (2.26-0ubuntu2.1) ...
Setting up manpages-dev (4.13-3) ...
Setting up libc6-dev:amd64 (2.26-0ubuntu2.1) ...
Setting up libitm1:amd64 (7.2.0-8ubuntu3) ...
Setting up fakeroot (1.21-1ubuntu2) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libgcc-7-dev:amd64 (7.2.0-8ubuntu3) ...
Setting up libstdc++-7-dev:amd64 (7.2.0-8ubuntu3) ...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up libalgorithm-diff-xs-perl (0.04-4build3) ...
Setting up gcc-7 (7.2.0-8ubuntu3) ...
Setting up g++-7 (7.2.0-8ubuntu3) ...
Setting up gcc (4:7.2.0-1ubuntu1) ...
Setting up g++ (4:7.2.0-1ubuntu1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.4ubuntu1) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...

上面有错误消息:

Get:2 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6 amd64 2.26-0ubuntu2.1 [2,780 kB]
Err:2 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6 amd64 2.26-0ubuntu2.1
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:b90d28f35eedf6fd218a90bf4c0634f5d60686e2f2ed38c4e283f581fbe8eef2
   - SHA1:54c460b9ca8746481342047236c6c3ceaec877a4 [weak]
   - MD5Sum:3069cbb5207a71f297b741c025de42ca [weak]
   - Filesize:2779898 [weak]
  Hashes of received file:
   - SHA256:0ed5fbdf0f3dcce4e428dd34b063043abcc8e56fed895fd58cb813fece65beb1
   - SHA1:f9b0e80321aa9b4a29fc7414072374366ecd5068 [weak]
   - MD5Sum:9a27e8f5f78d7c271cdc771f26a45e70 [weak]
   - Filesize:69466 [weak]
  Last modification reported: Wed, 17 Jan 2018 10:09:06 +0000

然后我尝试了make world.c,这是最简单的代码:

#include <stdio.h>
void main()
{
  printf(hello!);
}

最后,我在执行命令后遇到错误:make world 结果如下:

dophia@ubuntu:~/Downloads/datalab-handout$ make world
gcc -O -Wall -m32    world.c   -o world
In file included from world.c:1:0:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
 #include <bits/libc-header-start.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
<builtin>: recipe for target 'world' failed
make: *** [world] Error 1

如何解决此问题?我找了很长时间的解决方案,提前谢谢大家!

更新

我弄清楚问题出在哪里。 首先,安装没有完成,我在我所在的位置附近使用另一个软件源重新安装。

然后我发现错误仍然存​​在(不是world.c,CSAPP datalab中的另一个程序),这个错误发生在我试图在我的64位Ubuntu上编译32位程序时,所以我安装了32位C lirbrary,这里是:sudo apt-get install gcc-multillib,这是有效的!谢谢大家。

0 个答案:

没有答案