# Compiling under UNIX

This topic describes how to set environment variables and how to compile Natural Access applications in the UNIX operating system environment. It includes information about:

- Compiling

- Application linking

- Example compile and link

- Utility binaries

- Configuration files

## Compiling

When compiling an application, direct the compiler to /opt/nms/include for the Natural Access header files. These header files contain conditional compilation for different Natural Access target operating systems.

Define UNIX, UNIX_SVR4, and SOLARIS on the compilation command line, as follows:

-I/opt/nms/include -DUNIX -DUNIX_SVR4 -DSOLARIS

## Application linking

When linking for UNIX, link the Natural Access shared libraries (for example, libvcemgr.so or libcta.so) and the system dynamic linker, libdl.so, with the application program.

Specify the path where the Natural Access shared libraries reside. You can specify the path from the link line with a -L /opt/nms/lib command or by setting the LD_LIBRARY_PATH to /opt/nms/lib.

## Example compile and link

The following example shows the compiling and linking of myprog.c:

cc -I/opt/nms/include -DUNIX -DUNIX_SVR4 -DSOLARIS -L/opt/nms/lib -lcta -lvcemgr
-lswimgr -ladimgr -ldl myproc.c

Note: When building a multi-threaded application, you must specify the -lthread flag when compiling and linking. This flag generates and links code for multi-threaded applications.

## Utility binaries

Utility binaries are stored in /opt/nms/bin. Details concerning their use are described in Summary of the utilities.

Binaries of demonstration programs are located in the respective subdirectories in /opt/nms/ctaccess/demos.

## Configuration files

The /opt/nms/ctaccess/cfg directory contains a sample configuration file (cta.cfg) used with the ctavers utility and with ctdaemon. Refer to Service version confirmation: ctavers and Natural Access Server: ctdaemon for more information. Refer to Natural Access configuration file for more information about cta.cfg.