# Local Libsx Information

## Access to libsx

Libsx is currently compiled only for the Sun workstations running either Sunos 4.1.3 or Solaris 2.3. The libsx library is in `/usr/local/lib`, and the include files are in `/usr/local/include`.

## Compiling and Linking to libsx with C

### SunOS 4.1.x

The include files for X11 and libsx are in the standard places, so no special options are needed when compiling and linking.

### Solaris 2.3

The X11 libraries are not in a standard location. `-L/usr/x11/lib` must be used to specify the location of the libraries. `-R/usr/x11/lib` needs to be used so that the libraries are found when run-time linking is performed.

    cc -I/usr/x11/include -I/usr/local/include -c file.c
    cc -o file -L/usr/local/lib -lsx -L/usr/x11/lib -lXaw -lXmu -lXt -lX11 -lXext \\
     -R/usr/x11/lib -lsocket

## Using C++ with libsx

Since the libsx functions were compiled with a C compiler, the libsx include file must be bracketed with an `extern "C"` declaration.

    extern "C" {
    #include "libsx.h"
    }

### Sun Specific Instructions when using C++ (Solaris 2.3)

Due to a bug in the C++ compiler, the -R option appears to be ignored by the linker. Setting the environment variable LD_RUN_PATH should make run time linking work properly. This variable should be set during the compilation.

    setenv LD_RUN_PATH /opt/SUNWspro/lib:/usr/x11/lib

### Example Makefile for C++

    CPLUS = CC

    LIBS = -L/usr/local/lib -lsx -L/usr/x11/lib -lXaw -lXmu -lXt -lX11 -lXext \
     -R/usr/x11/lib -lsocket

    CCFLAGS = -I/usr/local/include -I/usr/x11/include
    #--------------------------------------------------------------------------
    all: gr

    gr: gr.o Graph.o
            $(CPLUS) -o gr gr.o Graph.o $(LIBS)

    gr.o: gr.cc
            $(CPLUS) -c $(CCFLAGS) gr.cc

    Graph.o: Graph.cc Graph.h
            $(CPLUS) -c $(CCFLAGS) Graph.cc