How to Compile X Programs


Compiling X programs now requires a lot of libraries to be specified.

If the program that you are compiling uses imake, and thus has an Imakefile, then everything should take care of itself. (Just run "xmkmf".)

If you are building a program that only uses Xlib (i.e. -lX11), then you need the following on the compile line:


and the following on your link line:

        -L/usr/openwin/lib -R/usr/openwin/lib -lX11 -lsocket -lnsl

The -L tells ld where to find the libraries. The -R is to record that path into the executable, so that the run time loader ( will know where to look for libraries when the program is executed. (This obviates the need for setting LD_LIBRARY_PATH.) The -lsocket and -lnsl are networking libraries, needed by Xlib, that used to be part of libc (under SunOS 4.1.3) but are now independent libraries.

If you are building a program that uses Xt, then you need, in addition to the above stuff (but before the -lX11 on the command line):

       -lXt -lSM -lICE

The SM and ICE stuff is because of changes that were made to X between X11R5 and X11R6 (which is what Solaris 2.6 uses).

If you are building Motif stuff, you need a bunch more stuff. See the Motif section for details.