2012-02-27 CPlusPlus0X

Giving up on static linkage

I've been struggling with getting the treading examples working but with no luck. An exception is thrown. Finally I got a hit on the net that suggested that the static linkage didn't work properly. It seems to be so. With dynamic linkage it works fine.

We thus need to change how we build and run the programs. Remember the tool chain description 2010-06-18_CPlusPlus0X?

We now need to drop the -static flag when we compile and link. We also need to add the -pthread flag for using threads.

$HOME/bin/gcc -std=c++0x -pthread

But this is not enough. We need to tell the runtime where the shared library files are located as they are not in the standard place. The environment variable LD_LIBRARY_PATH is used for that. Add this below in order to run the program.

export LD_LIBRARY_PATH=$HOME/lib

Replace with whatever location you have on your toolchain.

With this in place we are ready to look into the world of threads and threads support.