Created
August 31, 2012 06:22
-
-
Save mbohun/3549615 to your computer and use it in GitHub Desktop.
gcc-build-howto.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it is often a 'good idea' / requirement to use the 3-4 latest stable versions of gcc, | |
# this howto was used/tested with the following versions of gcc: | |
# - gcc-4.4.x | |
# - gcc-4.5.x | |
# - gcc-4.6.x | |
# - gcc-4.7.x | |
# get and decompress gcc | |
# | |
wget gcc-4.6.3.tar.bz2 | |
tar -jxvf gcc-4.6.3.tar.bz2 | |
# download the gcc prerequirements/libs (gmp, mpc, mpfr), | |
# decompress and rename them inside the gcc as shown bellow | |
# | |
# WARNING: there are compatibility/dependencies between mpc/mpfr, make | |
# sure you have compatible versions of them | |
# | |
cd gcc-4.6.3 | |
wget gmp-5.0.1.tar.bz2 | |
wget mpc-0.8.2.tar.gz | |
wget mpfr-3.0.0.tar.bz2 | |
mv gmp-5.0.1 gmp | |
mv mpc-0.8.2 mpc | |
mv mpfr-3.0.0 mpfr | |
cd .. | |
# create a separate build directory outside of the decompressed gcc archive | |
# | |
mkdir gcc_build | |
cd gcc_build | |
# from the build directory configure and build your new gcc; you can query | |
# your current 'gcc -v' to get the configure options that were used to | |
# build it, adjust them as you like and you are ready to build, example: | |
gcc -v | |
Using built-in specs. | |
COLLECT_GCC=gcc | |
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.5.3/libexec/gcc/i686-pc-linux-gnu/4.5.3/lto-wrapper | |
Target: i686-pc-linux-gnu | |
Configured with: ../gcc-4.5.3/configure --prefix=/usr/local/gcc-4.5.3 --enable-shared --enable-bootstrap --enable-languages=c,c++,fortran --enable-threads=posix | |
Thread model: posix | |
gcc version 4.5.3 (GCC) | |
# configure | |
# | |
# NOTE: if you do plan to debug/profile OpenMP programs on linux with valgrind, | |
# you have to configure your gcc (libgomp) with --disable-linux-futex, | |
# see the valgring/drd manual for details: | |
# http://valgrind.org/docs/manual/drd-manual.html#drd-manual.openmp | |
# | |
../gcc-4.6.3/configure --prefix=/usr/local/gcc-4.6.3 --enable-shared --enable-bootstrap --enable-languages=c,c++,fortran --enable-threads=posix | |
# build/make | |
# | |
make | |
# install your new version of gcc | |
# | |
sudo make install | |
# set the env and use it, C++ example: | |
# | |
export PATH=/usr/local/gcc-4.6.3/bin:$PATH | |
export LD_LIBRARY_PATH=/usr/local/gcc-4.6.3/lib:$LD_LIBRARY_PATH | |
export MANPATH=/usr/local/gcc-4.6.3/share/man:$MANPATH | |
cat test_cpp0x-lambda-00.cpp | |
#include <algorithm> | |
#include <iostream> | |
#include <iterator> | |
#include <vector> | |
using namespace std; | |
int main(int argc, char* argv[]) | |
{ | |
vector<int> v = {0, 1, 2, 6, 6, 666}; | |
std::copy(v.begin(), | |
v.end(), | |
std::ostream_iterator<int>(std::cout, ",")); | |
std::cout << std::endl; | |
int x = 42; | |
for_each(v.begin(), | |
v.end(), | |
[&](int& i){ i+=x; ++x;}); | |
std::copy(v.begin(), | |
v.end(), | |
std::ostream_iterator<int>(std::cout, ",")); | |
std::cout << std::endl << x << std::endl; | |
} | |
g++ -std=c++0x test_cpp0x-lambda-00.cpp | |
ldd a.out | |
linux-gate.so.1 => (0xffffe000) | |
libstdc++.so.6 => /usr/local/gcc-4.6.3/lib/libstdc++.so.6 (0x776ba000) | |
libm.so.6 => /lib/libm.so.6 (0x77671000) | |
libgcc_s.so.1 => /usr/local/gcc-4.6.3/lib/libgcc_s.so.1 (0x77656000) | |
libc.so.6 => /lib/libc.so.6 (0x774f6000) | |
/lib/ld-linux.so.2 (0x777a6000) | |
./a.out | |
0,1,2,6,6,666, | |
42,44,46,51,52,713, | |
48 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment