欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
GCC
小 (→安装 GCC) |
|||
第189行: | 第189行: | ||
*http://gcc.gnu.org/lists.html // mail lists | *http://gcc.gnu.org/lists.html // mail lists | ||
*http://docs.huihoo.com/gnu/ | *http://docs.huihoo.com/gnu/ | ||
− | [[Category: | + | |
+ | [[Category:GNU]] |
2010年8月17日 (二) 10:45的版本
Linux 中最重要的软件开发工具是GCC。GCC(GNU C Compiler)是GNU推出的功能强大、性能优越的多平台编译器,是GNU的代表作品之一。GCC是可以在多种硬体平台上编译出可执行程序的超级编译器,其执行效率与一般的编译器相比平均效率要高20%~30%。
目录 |
相关文档
- GCC Frontend HOWTO - http://ldp.huihoo.org/HOWTO/GCC-Frontend-HOWTO.html
相关工具
安装 GCC
Linux用户
在 Redhat 下通过 RPM包安装 GCC
install gcc rpm
获得 RPM包 http://fr2.rpmfind.net/linux/rpm2html/search.php?query=GCC&submit=Search+...
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
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://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
MS Windows用户
在linux 下 make hello.c
包含头文件,库的编译方式
g++ main.cpp -o example -I"../../include" -L"/usr/lib" ../../bin/linux-gcc/libIrrKlang.so -pthread
首先创建hello工程目录
mkdir hello //创建目录 cd hello //进入目录
然后建立三个文件
- hello.c
- configure.in // autoscan创建configure.scan,然后改名为configure.in,这里省略了这个步骤
- Makefile.am //Makefile模板
hello.c
#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 //执行hello程序
It's OK :)
$ make clean //清楚编译产生的中间文件和目标文件,为打包作准备
# 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
Solaris用户
Windows用户
下载 MinGW 软件包