> Problem solved. The issue is my distro does not seem to have a libX11.a
> anywhere, even inside "XFree86-devel-4.0.1-28mdk.i586.rpm". But 'ruby'
> doesn't actually need it with this configuration.

A typical place for libX11.so on RedHat and Mandrake Linux distributions is:

    /usr/X11R6/lib

I think the problem is that your linker line:

    gcc -g -O2 -rdynamic  main.o ext/extinit.o ext/tcltklib/tcltklib.a
        ext/tk/tkutil.a  libruby.a -ldl -lcrypt -lm
 libruby.a -ltk -ltcl -lX11 -lm
        -ldl -lc libruby.a -lc -o ruby

didn't specify this directory as a place to look for libraries. I think if
you had added the "-L/usr/X11R6/lib" flag, e.g.

    gcc -g -O2 -rdynamic  main.o ext/extinit.o ext/tcltklib/tcltklib.a
        ext/tk/tkutil.a  libruby.a -ldl -lcrypt -lm  libruby.a -ltk -ltcl
        -L/usr/X11R6/lib -lX11 -lm -ldl -lc libruby.a -lc -o ruby

you might not have gotten the link error ("... couldn't find -lX11").

Hope this helps,

Lyle