分类: LINUX
2008-03-29 23:05:52
I get it from Arnl documentations.
Installing GCC from Source Code:
--------------------------------
This is a summary of the GCC installation instructions:
Become a superuser, and untar the archive into
/usr/src or other directory (*not* /usr/local):
# cp gcc-3.4.1.tar.bz2 /usr/src/
# cd /usr/src
# tar -zxvf gcc-3.4.1.tar.gz
(creates /usr/src/gcc-3.4.1/...)
According to the gcc documentation, you compile the gcc sources into
an adjacent "gcc-build" directory, and then install the gcc
executables and libraries into a third directory--the one you'll
eventually reference to make ARNL applications.
Assuming you are still in /usr/src, create, then enter the build directory:
# mkdir gcc-build
# cd gcc-build
Now configure gcc, compile its sources into that build directory, only
have it build c and c++ languages and install the results into a
third, working directory:
# ../gcc-3.4.1/configure --enable-languages=c,c++ --prefix=/usr/local/gcc-3.4.1
# make
# make install
To have that version of gcc be your default compiler, make its bin/
directory the first entry in your PATH environment variable, typically
by inserting it into your personal ~/.bashrc or into the system-wide
/etc/bashrc:
export PATH=/usr/local/gcc-3.4.1/bin:$PATH
You also need to have the libraries with this version of gcc be the
ones that are used with your application which you can do by setting
your LD_LIBRARY_PATH environment variable, typically by inserting it
into your personal ~/.bashrc or into the system-wide /etc/bashrc:
export LD_LIBRARY_PATH=/usr/local/gcc-3.4.1/lib:$LD_LIBRARY_PATH
Log out, then log back in again and check to see what gcc version you're using:
# gcc -v
If you want to make sure that your executable will be using the right
libraries from the right places then use the ldd command to check:
# ldd /usr/local/Aria/examples/demo
The libraries used for libgcc_s.so and libstdc++ should be the ones
from /usr/local/gcc-3.4.1/lib.. so the output should have something
like these two lines (the numbers in parentheses don't matter):
ibstdc++.so.6 => /usr/local/gcc-3.4.1/lib/libstdc++.so.6 (0x40192000)
libgcc_s.so.1 => /usr/local/gcc-3.4.1/lib/libgcc_s.so.1 (0x40295000)
---------------------------------------------------------------------
---------------------------------------------------------------------
Installing the debugger:
------------------------
You may not need to install a debugger if the debugger on your system
works, however if you have an older system your debugger may not work
with the new gcc and so here are instructions on installing a new
debugger.
If you do need a new debugger we have found that gdb 6.1.1 works,
you'll want to compile it with gcc-3.4.1 (see above for installation
instructions).
To install a new gdb, download its sources archive from
Become a superuser, and untar the archive into /usr/src or other
directory, just *not* /usr/local:
# cp gdb-6.1.1.tar.bz2 /usr/src/
# cd /usr/src
# tar -zxvf gdb-6.1.1.tar.gz
(creates /usr/src/gdb-6.1.1/...)
Now go into the gdb directory and then configure gdb, having it
install the results into a second, working directory:
# cd gdb-6.1.1
# ./configure --prefix=/usr/local/gdb-6.1.1
# make
# make install
To have that version of gdb be your default debugger, make its bin/
directory the first entry in your PATH environment variable, typically
by inserting it into your personal ~/.bashrc or into the system-wide
/etc/bashrc:
export PATH=/usr/local/gdb-6.1.1/bin:$PATH