For minimal compilation to meet the C application binary interface (that is, a C++ program with only C support required) use:
demo% CC -xnolib test.cc -lc
To link libm statically into a single-threaded application on SPARC V8 architecure, use:
demo% CC -xnolib -Bstatic -lm -Bdynamic -lC_mtstubs -lw -lcx -lc
To link libm and libw statically, and link others dynamically:
demo% CC -xnolib -Bstatic -lm -lw -Bdynamic -lcx -lc