Here is the solution, you need to compile with the same flags the Perl was compiled with...

gcc -c example.c example_wrap.c -I/opt/ActivePerl-5.10/lib/CORE `perl -e 'use Config; print $Config{ccflags}'`