Example compile-and-link operations

A makefile for building Client-Library sample programs is provided in the %SYBASE%\%SYBASE_OCS%\sample\ctlib directory. An example fragment of makefile for a Windows Client-Library application for use by a Microsoft Visual C/C++ compiler, version 6.0 is as follows:

##################################################################
# Microsoft makefile for sample programs
#
#################################################################
MAKEFILE=MAKEFILE

!ifndef SYBASE
SYBASEHOME=c:\sybase
!else
SYBASEHOME=$(SYBASE)
!endif

COMPILE_DEBUG = 1

# Compiler AND linker flags
!ifdef COMPILE_DEBUG
CFLAGS = /W3 /MD /nologo /Zi /DWIN32
LFLAGS= /MAP /SUBSYSTEM:CONSOLE /DEBUG /DEBUGTYPE:cv 
!else
CFLAGS = /W3 /MD /nologo /Od /DWIN32
LFLAGS= /MAP /SUBSYSTEM:CONSOLE
!endif
ASYNCDEFS = -DUSE_SIG_HANDLER=0
HDRS = example.h exutils.h
MTHDRS = example.h thrdutil.h thrdfunc.h
# Where to get includes and libraries
#
# SYBASE is the environment variable for sybase home directory
#
SYBINCPATH =   $(SYBASEHOME)\$(SYBASE_OCS)\include
BLKLIB =       $(SYBASEHOME)\$(SYBASE_OCS)\lib\libsybblk.lib
CTLIB =        $(SYBASEHOME)\$(SYBASE_OCS)\lib\libsybct.lib 
CSLIB =	      $(SYBASEHOME)\$(SYBASE_OCS)\lib\libsybcs.lib
SYSLIBS= kernel32.lib advapi32.lib msvcrt.lib

# The generalized how to make an .obj rule
.c.obj:
	cl /I. /I$(SYBINCPATH) $(ASYNCDEFS) $(CFLAGS) -Fo$@ -c $<

all: exasync compute csr_disp getsend rpc blktxt i18n multthrd usedir firstapp
exconfig secct wide_rpc wide_dynamic wide_curupd wide_compute

uni: uni_firstapp uni_csr_disp uni_compute uni_blktxt uni_rpc

exasync compute csr_disp getsend rpc blktxt i18n multthrd usedir firstapp
exconfig secct twophase: $*.exe
		 @echo Sample '$*' was built

wide_rpc wide_dynamic wide_curupd wide_compute: $*.exe
		 @echo Sample '$*' was built

uni_firstapp uni_csr_disp uni_compute uni_blktxt uni_rpc: $*.exe
		 @echo Sample '$*' was built

sample.exe: sample.obj $(MAKEFILE)
	link $(LFLAGS) -out:$*.exe sample.obj $(SYSLIBS)

exasync.exe: ex_alib.obj ex_amain.obj exutils.obj $(MAKEFILE)
	link $(LFLAGS) -out:$*.exe ex_alib.obj ex_amain.obj exutils.obj
$(SYSLIBS) $(CTLIB)	$(CSLIB)
... compile and link lines for each Client-Library sample program goes here ...

clean:
		 -del *.obj 
		 -del *.map 
		 -del *.exe 
		 -del *.err
		 -del *.ilk
		 -del *.pdb

There are a few things to note in this example:

Refer to the appropriate compile-and-link Microsoft documentation for additional information.