Linux下C语言编程环境的搭建
关键词: Linux gcc make C语言 编程环境
要想在Linux下进行C语言编程,首先得搭建好一个编程环境。这里分别说明一下几个非常有用的软件包。
如果你对Linux下软件安装方法还不清楚,请参考文章“Linux下软件安装方法总结”http://zhoulifa.bokee.com/5444771.html
1、gcc
要进行C语言编程,首先得有个C语言的编译器,Linux下常用的是GNU C Compiler gcc。软件包的信息如下:
Package: gcc
Priority: optional
Section: devel
Installed-Size: 64
Maintainer: Ubuntu Core Developers
Original-Maintainer: Debian GCC Maintainers
Architecture: i386
Source: gcc-defaults (1.41ubuntu3)
Version: 4:4.1.1-6ubuntu3
Provides: c-compiler
Depends: cpp (>= 4:4.1.1-6ubuntu3), gcc-4.1 (>= 4.1.1-2)
Recommends: libc6-dev | libc-dev
Suggests: make, manpages-dev, autoconf, automake1.9, libtool, flex, bison, gdb, gcc-doc
Conflicts: gcc-doc (<< 1:2.95.3)
Filename: pool/main/g/gcc-defaults/gcc_4.1.1-6ubuntu3_i386.deb
Size: 5148
MD5sum: 50de0a13f56c9ac41f85ea7fcabde0b2
SHA1: c29cc1ea61d536d8ecb024fac83222c935a2703e
SHA256: 65103d0dbc2c7508184ac177a8ea5eb90a82d873b0fb7fd65b9764b691673708
Description: The GNU C compiler
This is the GNU C compiler, a fairly portable optimizing compiler for C.
.
This is a dependency package providing the default GNU C compiler.
Bugs: mailto:ubuntu-users@lists.ubuntu.com
Origin: Ubuntu
Task: ubuntu-desktop, kubuntu-desktop, xubuntu-desktop
我们从上面可以看出这个gcc软件是用来提供默认值的。从Depends可以看出要gcc真正工作必须有对应的cpp和gcc版本。
比如cpp-4.1和gcc-4.1、cpp-3.3和gcc-3.4
2、gcc-*
这里以gcc-4.1版本为例,该软件包信息如下:
Package: gcc-4.1
Priority: optional
Section: devel
Installed-Size: 1456
Maintainer: Ubuntu Core Developers
Original-Maintainer: Debian GCC Maintainers
Architecture: i386
Version: 4.1.1-13ubuntu5
Replaces: gcj-4.1 (<< 4.1.1), libssp0-dev (<< 4.1.1-6)
Provides: c-compiler, libssp0-dev
Depends: gcc-4.1-base (= 4.1.1-13ubuntu5), cpp-4.1 (= 4.1.1-13ubuntu5), binutils (>= 2.16.1cvs20051214), libgcc1 (>= 1:4.1.1-13ubuntu5), libc6 (>= 2.4-1)
Recommends: libc6-dev (>= 2.3.6-7), libmudflap0-dev (>= 4.1.1-13ubuntu5)
Suggests: gcc-4.1-doc (>= 4.1.1), gcc-4.1-locales (>= 4.1.1), libc6-dev-amd64, lib64gcc1 (>= 1:4.1.1-13ubuntu5)
Conflicts: gcj-4.1 (<< 4.1.1), libssp0-dev (<< 4.1.1-6)
Filename: pool/main/g/gcc-4.1/gcc-4.1_4.1.1-13ubuntu5_i386.deb
Size: 609694
MD5sum: 522696065e5152e9b8f2fe0c637340eb
SHA1: 3d7fedaccdd6180684849571f15bf75cc8cf0a56
SHA256: e77e3ed94f79d2bd6145fed9446c6216eb7c35a7a0e94148ae9f6d2f7c18d52e
Description: The GNU C compiler
This is the GNU C compiler, a fairly portable optimizing compiler for C.
Bugs: mailto:ubuntu-users@lists.ubuntu.com
Origin: Ubuntu
Task: ubuntu-desktop, kubuntu-desktop, xubuntu-desktop
3、cpp
gcc要进行程序编译,首先需要进行一个预编译过程。该过程对程序源代码进行预处理。
cpp软件包的信息如下:
Package: cpp
Priority: optional
Section: interpreters
Installed-Size: 96
Maintainer: Ubuntu Core Developers
Original-Maintainer: Debian GCC Maintainers
Architecture: i386
Source: gcc-defaults (1.41ubuntu3)
Version: 4:4.1.1-6ubuntu3
Depends: cpp-4.1 (>= 4.1.1-2)
Suggests: cpp-doc
Conflicts: cpp-doc (<< 1:2.95.3)
Filename: pool/main/g/gcc-defaults/cpp_4.1.1-6ubuntu3_i386.deb
Size: 31172
MD5sum: 1d16eb3da2478b7ded37d185968237b0
SHA1: 688cc7572783577825c5430252b04da31977c129
SHA256: a75d7c4446f45e94ec947307d90cf2776441baa78cd511192128e6cb1108f6a2
Description: The GNU C preprocessor (cpp)
The GNU C preprocessor is a macro processor that is used automatically
by the GNU C compiler to transform programs before actual compilation.
.
This package has been separated from gcc for the benefit of those who
require the preprocessor but not the compiler.
.
This is a dependency package providing the default GNU C preprocessor.
Bugs: mailto:ubuntu-users@lists.ubuntu.com
Origin: Ubuntu
Task: ubuntu-desktop, kubuntu-desktop, edubuntu-desktop, xubuntu-desktop
4、cpp-*
这里以cpp-4.1为例,软件包信息如下:
Package: cpp-4.1
Priority: optional
Section: interpreters
Installed-Size: 5196
Maintainer: Ubuntu Core Developers
Original-Maintainer: Debian GCC Maintainers
Architecture: i386
Source: gcc-4.1
Version: 4.1.1-13ubuntu5
Replaces: gcj-4.1 (<< 4.1.1)
Depends: gcc-4.1-base (= 4.1.1-13ubuntu5), libc6 (>= 2.4-1)
Suggests: gcc-4.1-locales (>= 4.1.1)
Conflicts: gcj-4.1 (<< 4.1.1)
Filename: pool/main/g/gcc-4.1/cpp-4.1_4.1.1-13ubuntu5_i386.deb
Size: 2309026
MD5sum: abfee8be3d7aeb0ad3eb4e7738838dca
SHA1: 8a51c79c2b961686b98617772b9da4800f173dbe
SHA256: 115aad59c02eee574066e21e6ed7a32bee1ed86e3abb73189645928832258ea0
Description: The GNU C preprocessor
A macro processor that is used automatically by the GNU C compiler
to transform programs before actual compilation.
.
This package has been separated from gcc for the benefit of those who
require the preprocessor but not the compiler.
Bugs: mailto:ubuntu-users@lists.ubuntu.com
Origin: Ubuntu
Task: ubuntu-desktop, kubuntu-desktop, edubuntu-desktop, xubuntu-desktop
5、libgcc1
gcc还依赖于libgcc1这个软件包。libgcc1是用于gcc软件自身的必须组件。软件包信息如下:
Package: libgcc1
Priority: required
Section: libs
Installed-Size: 68
Maintainer: Ubuntu Core Developers
Original-Maintainer: Debian GCC Maintainers
Architecture: i386
Source: gcc-4.1 (4.1.1-13ubuntu5)
Version: 1:4.1.1-13ubuntu5
Depends: gcc-4.1-base (= 4.1.1-13ubuntu5), libc6 (>= 2.4-1)
Filename: pool/main/g/gcc-4.1/libgcc1_4.1.1-13ubuntu5_i386.deb
Size: 21404
MD5sum: 879959bc964403be55aa096a8bb269f9
SHA1: 3a3cfd824e25a2ce9008d98da1269f5ffdb7507f
SHA256: 62f3f64daaa1dd19fc76d966718184d1e0e0ee9f733f7f955b8b09e27b69a7d1
Description: GCC support library
Shared version of the support library, a library of internal subroutines
that GCC uses to overcome shortcomings of particular machines, or
special needs for some languages.
Bugs: mailto:ubuntu-users@lists.ubuntu.com
Origin: Ubuntu
Task: minimal
6、libc6
C语言程序要能够运行,需要一些运行时库文件和一些库文件操作命令。libc6这个软件包就是用来提供这些的。这个软件包几乎是Linux系统自带的,因为所有C程序的运行都离不开此软件包。软件包信息如下:
Package: libc6
Priority: required
Section: base
Installed-Size: 9992
Maintainer: Ubuntu Core Developers
Original-Maintainer: GNU Libc Maintainers
Architecture: i386
Source: glibc
Version: 2.4-1ubuntu12.3
Replaces: ldso (<= 1.9.11-9), timezone, timezones, gconv-modules, libtricks, libc6-bin, netkit-rpc, netbase (<< 4.0)
Provides: glibc-2.3.6-2, glibc-2.3.5-3
Depends: locales (>= 2.3.11)
Suggests: locales, glibc-doc
Conflicts: strace (<< 4.0-0), libnss-db (<= 2.2-6.1.1), timezone, timezones, gconv-modules, libtricks, libc6-doc, libc5 (<< 5.4.33-7), libpthread0 (<< 0.7-10), libc6-bin, libwcsmbs, apt (<< 0.3.0), libglib1.2 (<< 1.2.1-2), netkit-rpc, wine (<< 0.0.20031118-1), cyrus-imapd (<< 1.5.19-15), e2fsprogs (<< 1.35-7), initrd-tools (<< 0.1.84.1), libterm-readline-gnu-perl (<< 1.15-2)
Filename: pool/main/g/glibc/libc6_2.4-1ubuntu12.3_i386.deb
Size: 4129182
MD5sum: 012994de4fa9093d6fdba6c2304ddb9a
SHA1: 187b850b1ac6153838ae2c1f8518342325ffe2ca
SHA256: 6ad0ee8cccb09117df4f6c02a275940b8bb27883219b205cad1840ccf870a790
Description: GNU C Library: Shared libraries
Contains the standard libraries that are used by nearly all programs on
the system. This package includes shared versions of the standard C library
and the standard math library, as well as many others.
Bugs: mailto:ubuntu-users@lists.ubuntu.com
Origin: Ubuntu
Task: minimal
(iwgh)