Tuesday, May 18, 2010

Wednesday, May 12, 2010

building gcc4.5 on linux

1) Download gcc sources:
svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_5-branch
2) Download other resources required:
wget ftp://gcc.gnu.org:21/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget ftp://gcc.gnu.org:21/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
wget ftp://gcc.gnu.org:21/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.64.tar.gz (might be needed)
3) build gmp, mpfr and mpc:
a) cd gmp-4.3.2
./configure --prefix=/usr/local
make
sudo make install
b) cd mpfr-2.4.2
./configure --prefix=/usr/local
make
sudo make install
c) cd mpc-0.8.1
./configure --prefix=/usr/local
make
sudo make install
NOTE: if it fails with 'relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC'
Make sure that you are using /usr/local/lib/libmpfr.so

4) cd gcc-4_5-branch
a) autoconf (it may ask for upgrading to 2.64)
b) LD_RUN_PATH=/usr/local/lib
export LD_RUN_PATH
LDFLAGS="-L/usr/local/lib -R/usr/local/lib"
export LDFLAGS
c) configure gcc:
./configure --prefix=/usr/local --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++ --disable-dssi --enable-plugin --with-cpu=generic --host=x86_64-redhat-linux --build=x86_64-redhat-linux --with-gmp=/usr/local/ --with-mpfr=/usr/local/ --with-mpc=/usr/local
d) make
e) sudo make install

Friday, April 9, 2010

CPU you selected does not support x86-64 instruction set

When does this occur:
It happens in case you have missed or incorrectly specified the target architecture.
Look for something like -m32 or -m64 in your compiler flags. It should be present and reflect target system.

Tuesday, February 9, 2010

Delete all pointers in a STL container

#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_object.hpp>

#include <algorithm>
#include <vector>
#include <iostream>

using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;

class A
{
   public:
   ~A() { std::cout << "A deleted\n"; }
};

int main()
{
     std::vector vec;
     vec.push_back(new A);
     vec.push_back(new A);

     std::for_each (vec.begin(), vec.end(), delete_ (arg1));
}

Friday, January 29, 2010

git cloning of svn repository's subdirectory

If you are interested in following a subdirectory of some svn repository, but do not want git to be bothered about previous history:

git svn clone -r HEAD --no-minimize-url url-goes-here

will do the job for you.

You can update to latest version of upstream (svn) repo

git svn rebase

Probably you do not want to mess with this branch, so check-out another branch to do your stuff and merge in local master later.

git checkout -b local_stuff