免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
论坛 操作系统 AIX AIX文档中心 gcc
最近访问板块 发新帖
查看: 2015 | 回复: 0
打印 上一主题 下一主题

[新手入门] gcc [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-05-12 21:26 |只看该作者 |倒序浏览
安装gcc的一种方法
作为自由软件的旗舰项目,Richard Stallman 在十多年前刚开始写作 GCC 的时候,还只是把它当作仅仅一个C 程序语言的编译器;GCC 的意思也只是 GNU C Compiler 而已。经过了这么多年的发展,GCC 已经不仅仅能支持 C 语言;它现在还支持 Ada 语言,C++ 语言,Java 语言,Objective C 语言,Pascal 语言,COBOL 语言,以及支持函数式编程和逻辑编程的 Mercury 语言,等等。而 GCC 也不再单只是 GNU C 语言编译器的意思了,而是变成了 GNU Compiler Collection 也即是 GNU 编译器家族的意思了
另一方面,说到 GCC 对于各种硬件平台的支持,概括起来就是一句话:无所不在。几乎所有有点实际用途的硬件平台,甚至包括有些不那么有实际用途的硬件平台,比如 Don Knuth 设计的 MMIX 计算机,GCC 都提供了完善的支持。
如果把我们自己的程序语言的实现建立于 GCC 之上,也立刻使得我们的程序语言的实现版本可以运行在几乎所有有用的硬件平台之上。这对于程序语言的作者来说,也是一个确实的有极大诱惑力的好处。
环境:
操作系统是IBM Aix5.1
机器为IBM,7044-170
Processor Type: PowerPC_POWER3
Number Of Processors: 1
Processor Clock Speed: 333 MHz
CPU Type: 64-bit
Kernel Type: 32-bit
1. Installing the RedHat Package Manager (RPM)
在安装GCC软件之前,必须安装RPM - the RedHat Package Manager。
你需要用installp安装RPM包, 下载此包的地址为:
ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/INSTALLP/ppc/rpm.rte

安装rpm 包,必须以root 用户操作,命令如下:
# installp -qacXgd rpm.rte rpm.rte
+-----------------------------------------------------------------------------+
Pre-installation Verification...
+-----------------------------------------------------------------------------+
Verifying selections...done
Verifying requisites...done
Results...
SUCCESSES
---------
Filesets listed in this section passed pre-installation verification
and will be installed.
Selected Filesets
-----------------
rpm.rte 3.0.5.36 # RPM Package Manager
>
FILESET STATISTICS
------------------
1 Selected to be installed, of which:
1 Passed pre-installation verification
----
1 Total to be installed
+-----------------------------------------------------------------------------+
Installing Software...
+-----------------------------------------------------------------------------+
installp: APPLYING software for:
rpm.rte 3.0.5.36
. . . . . > . . . . . . .
Licensed Materials - Property of IBM
5765E6100
& Copyright International Business Machines Corp. 2000, 2002.
& Copyright Regents of the University of California 1990, 1993, 1994, 1995.
& Copyright Jean-loup Gailly and Mark Adler, 1995 - 1998.
& Copyright The President and Fellows of Harvard University 1995, 1996.
& Copyright Julian R Seward, 1996 - 2000
& Copyright Sleepycat Software, 1990 - 2000
All rights reserved.
US Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
. . . . . >. . . .
Please wait...
Finished processing all filesets. (Total time: 8 mins 19 secs).
+-----------------------------------------------------------------------------+
Summaries:
+-----------------------------------------------------------------------------+
Installation Summary
--------------------
Name Level Part Event Result
-------------------------------------------------------------------------------
rpm.rte 3.0.5.36 USR APPLY SUCCESS
rpm.rte 3.0.5.36 ROOT APPLY SUCCESS
#
2.Using the RedHat Package Manager (RPM)
使用RPM的完整信息详见www.rpm.org. 基本的安装操作参数:
-i: install
-e: erase
-q: query
--help: help
rpm程序在/opt/freeware/bin/中
#cd /opt/freeware/bin/
# ./rpm
RPM version 3.0.5
Copyright & 1998 - Red Hat Software
This may be freely redistributed under the terms of the GNU GPL
usage: rpm {--help}
rpm {--version}
rpm {--initdb} [--dbpath ]
rpm {--install -i} [-v] [--hash -h] [--percent] [--force] [--test]
[--replacepkgs] [--replacefiles] [--root ]
[--excludedocs] [--includedocs] [--noscripts]
[--rcfile ] [--ignorearch] [--dbpath ]
[--prefix ] [--ignoreos] [--nodeps] [--allfiles]
[--ftpproxy ] [--ftpport ] [--justdb]
[--httpproxy ] [--httpport ]
[--noorder] [--relocate oldpath=newpath]
[--badreloc] [--notriggers] [--excludepath ]
[--ignoresize] file1.rpm ... fileN.rpm
rpm {--upgrade -U} [-v] [--hash -h] [--percent] [--force] [--test]
[--oldpackage] [--root ] [--noscripts]
[--excludedocs] [--includedocs] [--rcfile ]
[--ignorearch] [--dbpath ] [--prefix ]
[--ftpproxy ] [--ftpport ]
[--httpproxy ] [--httpport ]
[--ignoreos] [--nodeps] [--allfiles] [--justdb]
[--noorder] [--relocate oldpath=newpath]
[--badreloc] [--excludepath ] [--ignoresize]
file1.rpm ... fileN.rpm
rpm {--query -q} [-afpg] [-i] [-l] [-s] [-d] [-c] [-v] [-R]
[--scripts] [--root ] [--rcfile ]
[--whatprovides] [--whatrequires] [--requires]
[--triggeredby] [--ftpport] [--ftpproxy ]
[--httpproxy ] [--httpport ]
[--ftpport ] [--provides] [--triggers] [--dump]
[--changelog] [--dbpath ] [targets]
rpm {--verify -V -y} [-afpg] [--root ] [--rcfile ]
[--dbpath ] [--nodeps] [--nofiles] [--noscripts]
[--nomd5] [targets]
rpm {--setperms} [-afpg] [target]
rpm {--setugids} [-afpg] [target]
rpm {--freshen -F} file1.rpm ... fileN.rpm
rpm {--erase -e} [--root ] [--noscripts] [--rcfile ]
[--dbpath ] [--nodeps] [--allmatches]
[--justdb] [--notriggers] rpackage1 ... packageN
rpm {-b|t}[plciba] [-v] [--short-circuit] [--clean] [--rcfile ]
[--sign] [--nobuild] [--timecheck ] ]
[--target=platform1[,platform2...]]
[--rmsource] [--rmspec] specfile
rpm {--rmsource} [--rcfile ] [-v] specfile
rpm {--rebuild} [--rcfile ] [-v] source1.rpm ... sourceN.rpm
rpm {--recompile} [--rcfile ] [-v] source1.rpm ... sourceN.rpm
rpm {--resign} [--rcfile ] package1 package2 ... packageN
rpm {--addsign} [--rcfile ] package1 package2 ... packageN
rpm {--checksig -K} [--nopgp] [--nogpg] [--nomd5] [--rcfile ]
package1 ... packageN
rpm {--rebuilddb} [--rcfile ] [--dbpath ]
rpm {--querytags}
#
3.下载GCC软件包
到http://www-1.ibm.com/servers/aix/products/aixos/linux/download.html上下载gcc
2.9.aix51.020209 (5.1)
注意:installing package gcc-2.9.aix51.020209-4 needs 27Mb on the /opt filesystem
以root用户执行如下步骤:
# /opt/freeware/bin/rpm -i gcc-2.9.aix51.020209-4.aix5.1.ppc.rpm
#
# find / -name "gcc" -print
/opt/freeware/GNUPro/bin/gcc
/usr/bin/gcc
/usr/local/bin/gcc
你可以在shell的提示符号下键入gcc -v,萤幕上就会显示出你目前正在使用的GCC的版本.在我的系统上,执行
gcc -v的结果是:
# gcc -v
Reading specs from /usr/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-020209/specs
gcc version 2.9-aix51-020209
4.测试方法
只要执行gcc时,附加 -v这个参数(switch),就能找出你所用的这版gcc,自动帮你定义了什麽符号(symbols).例
如,我的机器看起来会像这样:
# echo 'main(){printf("hello world
");}' | gcc -E -v -
Reading specs from /usr/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-0202
09/specs
gcc version 2.9-aix51-020209
/usr/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-020209/cpp -lang-c -v
-iprefix /usr/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-020209/ -D__GN
UC__=2 -D__GNUC_MINOR__=9 -D_IBMR2 -D_POWER -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D
_AIX51 -D_LONG_LONG -D_IBMR2 -D_POWER -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51
-D_LONG_LONG -Asystem(unix) -Asystem(aix) -D__CHAR_UNSIGNED__ -D_ARCH_COM -
GNU CPP version 2.9-aix51-020209
#include "..." search starts here:
#include  search starts here:
/usr/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-020209/../../../../pow
erpc-ibm-aix5.1.0.0/include
/usr/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-020209/include
/opt/freeware/GNUPro/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-020209/../../
../../powerpc-ibm-aix5.1.0.0/include
/opt/freeware/GNUPro/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-020209/includ
e
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/opt/freeware/GNUPro/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/2.9-aix51-020209/../../
../../include/g++-3
/opt/freeware/GNUPro/include
End of omitted list.
# 1 ""
main(){printf("hello world
");}
#
通过编译程序文件的方式来测试编译器是否正常工作。
C编译器的测试
执行如下命令:
#cd /tmp
#vi testc.c
testc.c内容如下:
#include  
main()
{
printf("
GCC is OK!
");
}
编译test.c
# gcc -O test.c -o test
生成可执行文件test(通过ls命令可以看到)
运行 test
#./test
屏幕输出
GCC is OK!
说明GCC程序编译正确。

http://aixpdslib.seas.ucla.edu/packages/gcc.html下载bin的版本,解压就可以直接用了
[/url]

[url=http://www.unixgroup.net/forum/privmsg.php?mode=post&u=1226&sid=116a22eb2c529c4db3b244765ead3158]


[/url]
  



本文来自ChinaUnix博客,如果查看原文请点:[url]http://blog.chinaunix.net/u/2284/showart_25603.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP