作者:停止离开静悄悄 | 来源:互联网 | 2017-11-11 10:00
这里我以安装gcc为例。
1,修改源
debian-dk:~# vim /etc/apt/sources.list
deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 CD Binary-1 20070407-11:55]/ etch contrib main
2,安装gcc
debian-dk:~# apt-get install gcc
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
将会安装下列额外的软件包:
gcc-4.1 libssp0
建议安装的软件包:
manpages-dev autoconf automake1.9 libtool flex bison gcc-doc gcc-4.1-doc
gcc-4.1-locales libc6-dev-amd64 lib64gcc1 lib64ssp0
推荐安装的软件包:
libc6-dev libc-dev libmudflap0-dev
下列【新】软件包将被安装:
gcc gcc-4.1 libssp0
共升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 0 个软件未被升级 。
需要下载 0B/470kB 的软件包。
解压缩后会消耗掉 1401kB 的额外空间。
您希望继续执行吗?[Y/n]y
选中了曾被取消选择的软件包 libssp0。
(正在读取数据库 ... 系统当前总共安装有 52968 个文件和目录。)
正在解压缩 libssp0 (从 .../libssp0_4.1.1-21_i386.deb) ...
选中了曾被取消选择的软件包 gcc-4.1。
正在解压缩 gcc-4.1 (从 .../gcc-4.1_4.1.1-21_i386.deb) ...
选中了曾被取消选择的软件包 gcc。
正在解压缩 gcc (从 .../gcc_4.1.1-15_i386.deb) ...
正在设置 libssp0 (4.1.1-21) ...
正在设置 gcc-4.1 (4.1.1-21) ...
正在设置 gcc (4.1.1-15) ...
3,查看gcc信息,看是否安装好
debian-dk:~# man gcc
No manual entry for gcc
See 'man 7 undocumented' for help when manual pages are not available.
debian-dk:~# ls
debian-dk:~# find -name gcc
debian-dk:~# gcc --help
Usage: gcc [options] file...
Options:
-pass-exit-codes Exit with highest error code from a phase
--help Display this information
--target-help Display target specific command line options
(Use '-v --help' to display command line options of sub-processes)
-dumpspecs Display all of the built in spec strings
-dumpversion Display the version of the compiler
-dumpmachine Display the compiler's target processor
-print-search-dirs Display the directories in the compiler's search path
-print-libgcc-file-name Display the name of the compiler's companion library
-print-file-name=
Display the full path to library
-print-prog-name= Display the full path to compiler component
-print-multi-directory Display the root directory for versions of libgcc
-print-multi-lib Display the mapping between command line options and
multiple library search directories
-print-multi-os-directory Display the relative path to OS libraries
-Wa, Pass comma-separated on to the assembler
-Wp, Pass comma-separated on to the preprocessor
-Wl, Pass comma-separated on to the linker
-Xassembler Pass on to the assembler
-Xpreprocessor Pass on to the preprocessor
-Xlinker Pass on to the linker
-combine Pass multiple source files to compiler at once
-save-temps Do not delete intermediate files
-pipe Use pipes rather than intermediate files
-time Time the execution of each subprocess
-specs= Override built-in specs with the contents of
-std= Assume that the input sources are for
--sysroot= Use as the root directory for headers
for headers and libraries
-B Add to the compiler's search paths
-b Run gcc for target , if installed
-V Run gcc version number , if installed
-v Display the programs invoked by the compiler
-### Like -v but options quoted and commands not executed
-E Preprocess only; do not compile, assemble or link
-S Compile only; do not assemble or link
-c Compile and assemble, but do not link
-o Place the output into
-x Specify the language of the following input files
Permissible languages include: c c++ assembler none
'none' means revert to the default behavior of
guessing the language based on the file's extension
Options starting with -g, -f, -m, -O, -W, or --param are automatically
passed on to the various sub-processes invoked by gcc. In order to pass
other options on to these processes the -W options must be used.
For bug reporting instructions, please see:
http://gcc.gnu.org/bugs.html>.
For Debian GNU/Linux specific bug reporting instructions, please see:
.
4,ok,写个helloworld试试gcc
debian-dk:~# ls
debian-dk:~# vim hello.c
debian-dk:~# gcc -o hello hello.c
hello.c:1:19: error: stdio.h: 没有那个文件或目录
hello.c: In function ‘main’:
hello.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
出问题了,找不到stdio.h,那是因为没装库,装上libc6-dev就行了,往下走
5,安装libc库
debian-dk:~# apt-get install libc-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
注意,我选了 libc6-dev 而非 libc-dev
将会安装下列额外的软件包:
libc6-dev linux-kernel-headers
建议安装的软件包:
glibc-doc manpages-dev
下列【新】软件包将被安装:
libc6-dev linux-kernel-headers
共升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。
需要下载 0B/4591kB 的软件包。
解压缩后会消耗掉 22.2MB 的额外空间。
您希望继续执行吗?[Y/n]y
选中了曾被取消选择的软件包 linux-kernel-headers。
(正在读取数据库 ... 系统当前总共安装有 53056 个文件和目录。)
正在解压缩 linux-kernel-headers (从 .../linux-kernel-headers_2.6.18-7_i386.deb) ...
选中了曾被取消选择的软件包 libc6-dev。
正在解压缩 libc6-dev (从 .../libc6-dev_2.3.6.ds1-13_i386.deb) ...
正在设置 linux-kernel-headers (2.6.18-7) ...
正在设置 libc6-dev (2.3.6.ds1-13) ...
6,ok装好了,再来看看helloworld
debian-dk:~# gcc -o hello hello.c
debian-dk:~# ls
hello hello.c
debian-dk:~# ./hello
hello debian world!
7,finished!