Pass libraries at the end of command line.
Ubuntu 11.10 has --as-needed on by default, which means that libraries must be specified after the sources/objects that use those libraries, even for shared libraries.
See http://www.gentoo.org/proj/en/qa/asneeded.xml