First check to see if you have a libfcgi install via any packages already:
grep libfcgi /var/sadm/install/conents
If grep finds anything you should try to use the command line option "-R" to set the runtime shared library path to the directory that contains the libfcgi.*so* shared library. See "man ld" for details on the "-R" option even though you need to pass "-R" to gcc since gcc runs ld for you.
If grep doesn't find anything you need to install a libfcgi. Possible source of this are:
1. the Sun Solaris 10 companion CD or DVD. Check the sun web sites that you get Solaris 10 from for this. It might also be available via http://companion.sunfreeware.com/ Package name is SUNWfcgi
2. OpenCSW or Blastwave. Use a search engine to locate them. The package is CSWfastcgi and I'm inclined to believe that Blastwave has it but OpenCSW does not.
3. Sunfreeware see sunfreeware.com I don't know the package name if any.
4. source code http://www.fastcgi.com/dist/
Even after installing libfcgi you will still need "-R" as above.