compiling_and_linking

Document Sample
compiling_and_linking Powered By Docstoc
					Makefiles for OPSEC Applications ................................................................................................................... 2
   Compilers and Linkers ............................................................................................................................ 2
   Link Options............................................................................................................................................. 2
      Libraries ................................................................................................................................................. 2
 UNIX Platforms ............................................................................................................................................. 3
   System Libraries ...................................................................................................................................... 3
      Linux ...................................................................................................................................................... 3
      Solaris .................................................................................................................................................... 3
   CFLAGS ................................................................................................................................................... 3
      Linux ...................................................................................................................................................... 3
      Solaris .................................................................................................................................................... 3
 WIN32 Platforms ........................................................................................................................................... 4
   Link Options............................................................................................................................................. 4
   Link libraries ............................................................................................................................................ 4
   System Libraries ...................................................................................................................................... 4
 Sample Makefile (gmake) for Unix platforms.............................................................................................. 5
                                   Makefiles for OPSEC Applications
This file describes how to compile and link OPSEC applications with OPSEC NG.
The file contains the compilers to use, the libraries required, the compilation flags, how to set MSDEV environment and a simple
Makefile sample for Unix systems


Compilers and Linkers
Platform                         C Compiler                        C linker
Solaris                          cc forte (6.1)                    CC forte (6.1)
Linux                            gcc 2.95.1                        gcc 2.95.1
WIN NT 4.0                       MSDEC 6.0 SP4                     MSDEC 6.0 SP4



Link Options
OPSEC SDK NG-Beta supports 4 type of links for each platform. These types are:

                                       Static                                  Dynamic
Release                                release.static                          release.dynamic
Debug                                  debug.static                            debug.dynamic

Libraries
Following is a list of libraries required to link an OPSEC application.
Library Names
It is assumed that Unix libraries have the prefix ‘lib’ and the suffixed ‘.a’ (for static libraries) or ‘.so’ (for shared objects).
On NT systems the suffix (extension) is ‘.lib’ for static libraries or ‘.dll’ for dynamic libraries.

OPSEC Applications Static Libraries list:
 opsec, sicauth, sic, cp_policy, skey, ndb, ckpssl, cpcert, cpcryptutil, cpprng, cpbcrypt, cpca, asn1cpp, cpopenssl, Encode,
   ComUtils, Resolve, DataStruct, OS, cpprod50


OPSEC CPMI Applications Static Libraries list:
 CPMIClient, CPMIBase, CPSrvIS, opsec, sicauth, sic, cp_policy, skey, objlibclient, ndb, ckpssl, cpcert, cpcryptutil, cpprng,
   cpbcrypt, cpca, asn1cpp, cpopenssl, Encode, ComUtils, Resolve, DataStruct, OS, cpprod50


OPSEC Applications Dynamic Libraries list:
 opsec, cpsic, sicauth, sic, cp_policy, skey, ndb, ckpssl, cpcert, cpcryptutil, cpprng, cpbcrypt, cpca, cpopenssl, Encode,
   ComUtils, Resolve, DataStruct, OS, EventUtils, Resolver, cpprod50


OPSEC CPMI Applications Dynamic Libraries list:
 CPMIClient, CPMIBase, CPSrvIS, opsec, cpsic, messaging, sicauth, sic, cp_policy, skey, objlibclient, objlib, ndb, fwsetdb,
   ckpssl, cpcert, cpcryptutil, cpprng, cpbcrypt, cpca, cpopenssl, Encode, ComUtils, Resolve, DataStruct, OS, EventUtils,
   Resolver, cpprod50
UNIX Platforms

System Libraries
In addition to OPSEC NG libraries one must use also some system libraries. The following section lists the required systems
libraries:
Linux
The following should be installed under Red Hat 6.1:
 libelf-0.6.4-4 (a package)
 libcpc++-3-libc6.1-2-2.10.0 (a library)

System libraries required:
 pthread, resolv, dl, pam, nsl, elf, cpc++-3-libc6.1-2-2.10.0

Solaris
System libraries required:
 thread, posix4, resolv, socket, nsl, dl, intl, m, c, w, kstat, kvm, elf




CFLAGS
The following flags are required for compilation of OPSEC applications (‘INCLUDE’ variable should point to the include
directory of OPSEC NG-Beta package):
Linux
         CFLAGS += -I$(INCLUDE) -Dlinux -DUNIXOS
Solaris
         CFLAGS += -xtarget=ultra -xs -DUNIXOS -KPIC -mt -I$(INCLUDE) -xildoff
WIN32 Platforms
This section explains how to construct a Visual Studio 6.0 workspace for an OPSEC application.


Link Options

The following table lists - for every compilation type - the ‘Code Generation’ option, the preprocessor flags and the list of libraries
that are required to link OPSEC application.
To set ‘Code Generation’ option:
1. In Project Settings (Alt+F7), choose the ‘C/C++’ tab
2. In the ‘Category’ combo box, select ‘Code Generation’.
3. In the ‘Use run-time Library’ set the option according to the table below.

To set preprocessor flags:
1. In Project Settings (Alt+F7), choose the ‘C/C++’ tab
2. In the ‘Category’ combo box, select ‘Preprocessor’.
3. In the ‘Preprocessor definitions’ add the preprocessor flag.

                       Use run-time Library              Preprocessor definitions      Libraries list
Release.dynamic        Multithreaded DLL                 OPSEC_DLL_IMPORT              OPSEC Applications Static
                                                                                       Libraries list:
Debug.dynamic          Debug Multithreaded DLL           OPSEC_DLL_IMPORT
Release.static         Multithreaded DLL                                               OPSEC Applications Static
                                                                                       Libraries list:
Debug.static           Debug Multithreaded DLL                                         OPSEC Applications Static
                                                                                       Libraries list:


Link libraries

To complete the link, the user should add to the Link list the libraries that are required to link OPSEC application.
To add libraries to the libraries link list:
1. In Project Settings (Alt+F7), choose the ‘Link’ tab.
2. Add to ‘Object/library modules’ the relevant libraries (see Libraries above).

When using a dynamic link one should add to the link list only the following libraries:
CPMIClient, CPSrvIS, opsec


System Libraries
The system libraries that are required (for all type of links):
wsock32.lib, advapi32.lib, ole32.lib.
Sample Makefile (gmake) for Unix platforms

#
# Makefile for opsec applications
#

#
# set the executable name
#
EXE_NAME = ela_client
EXE_NAME_DYN = ela_client_dyn
#
# define the object (*.o) files that compose the executable
#
OBJ_FILES        =          $(ARCH)/ela_client.o $(ARCH)/ela_p.o

#
# set compiler (CC) and linker (LD)
#
ifeq ($(ARCH), linux22)
CC       =       /gnu-2.95.1.linux22/bin/gcc
LD       =       /gnu-2.95.1.linux22/bin/gcc
else
ifeq ($(ARCH), solaris2)
CC       =       cc
LD       =       CC
endif #solaris2
endif #linux22

#
# set 'PKG_DIR' to points to the OPSEC SDK package directory
#
PKG_DIR        =        /opsec_sdk/pkg_rel


#
# set 'LIB_DIR' to point to the directory that contains the libraries
# this should be one of: release.static, release.dynamic, debug.static, debug.dynamic
#
LIB_DIR                    = $(PKG_DIR)/lib/release.static

#
# Static (release or debug) libraries required for link
#

STATIC_LIBS = \
      -lopsec \
      -lsicauth -lsic \
      -lcp_policy \
      -lskey \
      -lndb \
      -lckpssl -lcpcert \
      -lcpcryptutil -lcpprng \
      -lcpbcrypt -lcpca \
        -lasn1cpp \
        -lcpopenssl \
        -lEncode -lComUtils \
        -lResolve -lDataStruct \
        -lOS \
        -lcpprod50

#
# Dynamic (release or debug) libraries required for link
#

DYNAMIC_LIBS = \
     -lopsec \
     -lcpsic \
     -lsicauth -lsic \
     -lcp_policy \
     -lskey \
     -lndb \
     -lckpssl -lcpcert \
     -lcpcryptutil -lcpprng \
     -lcpbcrypt -lcpca \
     -lcpopenssl \
     -lEncode -lComUtils \
     -lResolve -lDataStruct \
     -lOS -lEventUtils -lResolver \
     -lcpprod50

#
# set system libraries and CFLAGS
#
ifeq ($(ARCH), linux22)
LIBS =            -lpthread -lresolv -ldl -lpam -lnsl -lelf -lcpc++
CFLAGS            += -I$(PKG_DIR)/include -Dlinux -DUNIXOS=1 -DDEBUG

else

ifeq ($(ARCH), solaris2)
LIBS =          -lthread -lposix4 -lresolv -lsocket -lnsl -ldl -lintl -lm -lc -lw -lkstat -lkvm -lelf
CFLAGS          += -xtarget=ultra -xs -g -DDEBUG -DUNIXOS -KPIC -mt -I$(PKG_DIR)/include -xildoff

endif   #solaris2
endif   #linux22

#
# compilations and link commands
#
$(ARCH)/%.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $*.c

$(EXE_NAME): $(OBJ_FILES)
      $(LD) $(CFLAGS) -L$(LIB_DIR) -o $(ARCH)/$@ $(OBJ_FILES) $(STATIC_LIBS) $(LIBS)

$(EXE_NAME_DYN): $(OBJ_FILES)
       $(LD) $(CFLAGS) -L$(LIB_DIR_DYN) -o $(ARCH)/$@ $(OBJ_FILES) $(DYNAMIC_LIBS) $(LIBS)
clean:
       rm $(ARCH)/*.o $(ARCH)/$(EXE_NAME) $(ARCH)/$(EXE_NAME_DYN)

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:13
posted:9/7/2012
language:Unknown
pages:7