I believe I had a *slightly* similar problem while compiling DBI for HP-UX.
IIRC, the solution's a little easier on Solaris, but I ended up statically linking DBI into the Perl executable, and linking libgcc into mysql - something that involved fiddling with the libtool script for mysql.
Be warned: I'm not sure that this will solve your problem, so please consider it an option, rather than the only course of action
Either way the
MySQL Docs have some information that may be helpful
Hope that helps
davis