RHEL/CentOS Linux安装核心开发工具Automake,Gcc(C/C ++),Perl,Python和调试器

时间:2020-01-09 10:34:13  来源:igfitidea点击:

问题:
从命令行或shell提示符安装CentOS或RHEL或Fedora Linux之后,如何安装所有开发人员工具,例如GNU GCC C/C ++编译器,make和其他工具?

解决方法:
您需要在RHEL/CentOS/Fedora/Scientific/Red Hat Enterprise Linux上安装"开发工具"组。
这些工具包括核心开发工具,例如automake,gcc,perl,python和调试器,它们是编译软件和构建新rpm所必需的:

  • flex
  • gcc c/c++ 编译器
  • redhat-rpm-config
  • strace
  • rpm-build
  • make
  • pkgconfig
  • gettext
  • automake
  • strace64
  • gdb
  • bison
  • libtool
  • autoconf
  • gcc-c++ 编译器
  • binutils和所有依赖项。

安装

打开终端或通过ssh会话登录,然后以root用户身份键入以下yum命令:

$ sudo yum group install "Development Tools"

或者

# yum groupinstall 'Development Tools'

输出示例:

Loading "fastestmirror" plugin
Loading mirror speeds from cached hostfile
* base: mirror.steadfast.net
* updates: dist1.800hosting.com
* addons: centos.mirrors.tds.net
* extras: dist1.800hosting.com
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirror.steadfast.net
* updates: dist1.800hosting.com
* addons: centos.mirrors.tds.net
* extras: dist1.800hosting.com
Package make - 1:3.81-3.el5.i386 already installed and latest version
Package gettext - 0.14.6-4.el5.i386 already installed and latest version
Package binutils - 2.17.50.0.6-6.el5.i386 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package automake.noarch 0:1.9.6-2.1 set to be updated
---> Package frysk.i686 0:0.0.1.2008.03.19.rh1-1.el5 set to be updated
--> Processing Dependency: libgcj.so.7rh for package: frysk
--> Processing Dependency: glib-java >= 0.2.6 for package: frysk
---> Package autoconf.noarch 0:2.59-12 set to be updated
--> Processing Dependency: imake for package: autoconf
---> Package rcs.i386 0:5.7-30.1 set to be updated
---> Package strace.i386 0:4.5.16-1.el5.1 set to be updated
---> Package redhat-rpm-config.noarch 0:8.0.45-24.el5 set to be updated
---> Package elfutils.i386 0:0.125-3.el5 set to be updated
--> Processing Dependency: libdw.so.1 for package: elfutils
...........
....
..
Transaction Summary
=============================================================================
Install    105 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         

Total download size: 127 M
Is this ok [y/N]: y
Downloading Packages:
(1/105): python-numeric-2 100% |=========================| 751 kB    00:12     
(2/105): xorg-x11-fonts-b 100% |=========================| 3.7 MB    01:03     
(3/105): pfmon-3.2-0.0609 100% |=========================| 656 kB    00:10     
(4/105): automake14-1.4p6 100% |=========================| 205 kB    00:03     
(5/105): libtool-1.5.22-6 100% |=========================| 680 kB    00:11     
(6/105): systemtap-0.6.2- 100% |=========================| 1.3 MB    00:22

现在,您可以编译和使用系统上的任何应用程序。

验证

要显示Gnu gcc/c/c ++编译器版本,请输入:

$ gcc --version

输出示例:

gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

C程序示例

使用文本编辑器(例如vi/vim),如下创建一个名为hello.c的文本文件:

/* hello.c - A sample C program for CentOS/RHEL */
#include <stdio.h>
int main(void)
{
printf("Hello, world!\n");
return 0;
}

编译类型:

$ make hello

要执行程序类型:

$ ./hello