I'll try to make myself clearer.
I have the paths '/usr/local/Trolltech/Qt-4.0.1/lib' and '/usr/local/lib' in the directories section for the linker. Loading the qt libraries actually works well. It is the dynamic coin3d libraries that are not found and loaded during run time. So yes, everything compiles fine and it is when running the app I get the error.
I also can't use environment variables like QTDIR to specify directories. I thought maybe the Settings->Environment would be the answer, but when I try this codeblocks crashes so I guess this is something that is not yet implemented.