GCC

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
 
第1行: 第1行:
== 安装 GCC ==
+
==安装 GCC==
  
 
在 Redhat 下通过 RPM包安装 GCC
 
在 Redhat 下通过 RPM包安装 GCC

2006年7月14日 (五) 15:34的版本

安装 GCC

在 Redhat 下通过 RPM包安装 GCC

install gcc rpm

rpm -Uvh gcc-3.2.3-34.i386.rpm glibc-devel-2.3.2-95.20.i386.rpm libgcc-3.2.3-34.i386.rpm cpp-3.2.3-34.i386.rpm glibc-headers-2.3.2-95.20.i386.rpm glibc-kernheaders-2.4-8.34.i386.rpm

gcc --version


http://www.linuxfromscratch.org/lfs/view/stable/chapter03/packages.html

All Packages


install gcc 3.4.3

http://gcc.gnu.org/install/

The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:


tar -xvf *.tar

tar -zxvf *.tar.gz


tar -xjvf gcc-3.4.3.tar.bz2


cd gcc-3.4.3

mkdir -v ../gcc-build

cd ../gcc-build


../gcc-3.4.3/configure --prefix=/tools \

   --libexecdir=/tools/lib --with-local-prefix=/tools \
   --disable-nls --enable-shared --enable-languages=c


or

../gcc-3.4.3/configure --prefix=/usr/local --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-languages=c --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux



make bootstrap // make long time


make install


ln -vs gcc /tools/bin/cc


[root@RHELAS3 gcc-build]# /tools/bin/cc --version

cc (GCC) 3.4.3

Copyright (C) 2004 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.


[huihoo@RHELAS3 5]$ /tools/bin/cc helloworld.cpp -o helloworld

cc: helloworld.cpp: C++ compiler not installed on this system


run testsuite


[huihoo@RHELAS3 testsuite]$ gcc -v

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux

Thread model: posix

gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-53)


libstdc++ install


http://gcc.gnu.org/libstdc++/

http://mirrors.kernel.org/gnu/


Porting libstdc++-v3

http://gcc.gnu.org/onlinedocs/porting/


[huihoo@RHELAS3 libstdc++-v3]$ ./configure

configure: error: cannot find install-sh or install.sh in ./../..



./configure --prefix=/usr/local --mandir=/usr/share/man --infodir=/usr/share/info --enable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-cstdio --enable-clocale --enable-libstdcxx-allocator --enable-threads --enable-threads=posix --enable-libstdcxx-debug --enable-c99 --enable-long-long --enable-fully-dynamic-string --enable-concept-checks --enable-libstdcxx-pch --disable-hosted-libstdcxx


RHEL3

/usr/lib/gcc/i386-redhat-linux/3.4.3/libstdc++.so

/usr/lib/gcc/i386-redhat-linux/3.4.3/libstdc++.a

/usr/lib/libstdc++.so.6

/usr/lib/libstdc++.so.6.0.3

在linux 下 make hello.c

mkdir hello

cd hello


建立三个文件

hello.c

configure.in // autoscan创建configure.scan,然后改名为configure.in,这里省略了这个步骤

Makefile.am


hello.c


  1. include <stdio.h>


int

main(int argc,char *argv[])

{

       printf("hello world\n");
       return 0;

}



在configure.in里加入

AC_INIT(hello.c)

AM_INIT_AUTOMAKE(hello,0.1)

AC_PROG_CC

AC_OUTPUT(Makefile)


在Makefile.am里加入

UTOMAKE_OPTIONS=foreign

bin_PROGRAMS=hello

hello_SOURCES=hello.c


and touch new files: NEWS, README,AUTHORS, ChangeLog


然后执行

$ aclocal

$ autoconf

$ automake --add-missing

$ ./configure

$ make

$ ./hello


It's OK :)


$ make clean


  1. make install // 将hello安装到 /usr/local/bin

/usr/local/bin/hello


$ make dist

create package file: hello-0.1.tar.gz


$ make distcheck // 生成发布软件包并对其进行测试检查,以确定发布包的正确性。

提示: hello-0.1.tar.gz is ready for distribution

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱