Home    |    Concepts   |   API   |   Samples
Samples
Building C API Samples
The following illustrates how to build ArcSDE C API programs on UNIX platforms. You will need an ANSI compliant C compiler for your specific platform to build ArcSDE C API programs.
  1. Install the proper ArcSDE client. See Installation guide for more information. In this example the ArcSDE client is installed into the directory /esri3/users/test/sdehome.
     
  2. Set the environment variable SDEHOME to point to the directory where your ArcSDE client is installed. In this example, set SDEHOME to point to /esri3/users/test/sdehome.

    setenv SDEHOME /esri3/users/test/sdehome

     
  3. Set the platform specific library path variable to the $SDEHOME/lib directory.

    SUN, TRU64 & LINUX:
    setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:$SDEHOME/lib

    AIX :
    setenv LIBPATH $LIBPATH:$SDEHOME/lib

    HP-UX :
    setenv SHLIB_PATH $SHLIB_PATH:$SDEHOME/lib

     
  4. Build the ArcSDE C API program using a standard ANSI compliant C compiler. The build options are specific to each platform and the type of executable (32 or 64 bit) required. The following examples list build options to compile an ArcSDE C API program layer_test.c into an executable called layer_test for each platform. You can put a build command line into UNIX shell file if needed.

    (1) Build 32bit executable on SunOS

    cc -mt -Xa -xCC -KPIC -O -DSOLARIS -Dunix -I$SDEHOME/include -L$SDEHOME/lib -L/lib -L/usr/ucblib -R/usr/openwin/lib:/usr/ucblib:/usr/dt/lib -L. layer_test.c -o layer_test -Bdynamic -lelf -lsocket -lnsl -ldl -lthread -lsunmath_mt -lmtsk -lintl -lc -lposix4 -lm -lrt -lxerces-c -licuuc -lCrun -lCstd -lpe -lsg –lsde

    (2) Build 64bit executable on SunOS

    cc -mt -Xa -xCC -xarch=v9 -O -DSOLARIS -Dunix -DSDE64 -I$SDEHOME/include -L$SDEHOME/lib -L/lib -L/usr/ucblib -R/usr/openwin/lib:/usr/ucblib:/usr/dt/lib -L. layer_test.c -o layer_test -Bdynamic -lelf -lsocket -lnsl -ldl -lthread -lsunmath -lmtsk -lintl -lc -lposix4 -lm -lrt -lxerces-c -licuuc -lCrun -lCstd -lpe -lsg –lsde

    (3) Build 32bit executable on AIX

    xlc_r -qcpluscmt -DRS6000 -DAIX -Dunix -I$SDEHOME/include -L/usr/lib/threads -L/usr/lib -L$SDEHOME/lib -L. -bnoipath -brtl -bh:8 -bbigtoc -bpT:0x10000000 -bpD:0x20000000 -o layer_test layer_test.c -bexpall -bhalt:5 -lpthreads -ldl -lc_r -lm -lc -lbsd -lc_r -lbsd -ldl -licuuc -lpe -lsde -lsg

    (4) Build 64bit executable on AIX

    xlc_r -q64 -qcpluscmt -DRS6000 -DSDE64 -Dunix -I$SDEHOME/include -L/usr/lib/threads -L/usr/lib -L$SDEHOME/lib -L. -bnoipath -brtl -bh:8 -bbigtoc -bpT:0x10000000 -bpD:0x20000000 -o layer_test layer_test.c -bexpall -bhalt:5 -lpthreads -ldl -lc_r -lm -lc -lbsd -lc_r -lbsd -ldl -licuuc -lpe_64 -lsde_64 -lsg_64

    (5) Build 32bit executable on HPUX

    cc -Wl,+s +Z -DFIX_ALGN -DHP -Dhpux -Dunix -D__POSIX_C_SOURCE=199506L -D_REENTRANT -D_THREAD_SAFE -D_POSIX_THREADS +DS2.0a +DA1.1 -I$SDEHOME/include -L$SDEHOME/lib -L. layer_test.c -o layer_test -lcl -lpthread -ldld -lnsl -lm -lrt -lc -lCsup -licuuc -lpe -lsg -lsde

    (6) Build 64bit executable on HPUX

    cc +O2 +DS2.0a +DA2.0W -DSDE64 -DHP64 -DHP -Dunix -D__POSIX_C_SOURCE=199506L -D_REENTRANT -D_THREAD_SAFE -D_POSIX_THREADS -I$SDEHOME/include -L/lib -L$SDEHOME/lib -L. layer_test.c -o layer_test -lcl -lpthread -ldld -lnsl -lm -lrt -lCsup -licuuc -lpe -lsg -lsde

    (7) Build 32bit executable on LINUX

    gcc -DLINUX -DLINUX_IA32 -DSDE_EXEC -I$SDEHOME/include -L$SDEHOME/lib -L. -o layer_test layer_test.c -lpe -lsg -lsde -licuuc -lm -lgcc -lc -lpthread –ldl

    (8) Build 64bit executable on Compaq Tru64

    cc -std -ieee -Dunix -O -DAXPOSF -DA_OSF -DANSI -pthread -I$SDEHOME/include -L/usr/ucblib -L$SDEHOME/lib -L. layer_test.c -o layer_test -lpthread -lc -lm -lmach -lrt -lexc -licuuc -lpe -lsg -lsde
     
  5. You can also build executables in two steps: compile source files into object files first, and then build executables from these object files. The following example builds a 64bit executable on SunOS using two steps:

    #Compile layer_test.c into layer_test.o
    cc -mt -Xa -xCC -xarch=v9 -O -DSOLARIS -Dunix -DSDE64 -I$SDEHOME/include -L$SDEHOME/lib -L/lib -L/usr/ucblib -R/usr/openwin/lib:/usr/ucblib:/usr/dt/lib -L. -c layer_test.c -o layer_test.o

    #Build executable layer_test from layer_test.o
    cc -mt -Xa -xCC -xarch=v9 -O -DSOLARIS -Dunix -DSDE64 -I$SDEHOME/include -L$SDEHOME/lib -L/lib -L/usr/ucblib -R/usr/openwin/lib:/usr/ucblib:/usr/dt/lib -L. layer_test.o -o layer_test -Bdynamic -lelf -lsocket -lnsl -ldl -lthread -lsunmath -lmtsk -lintl -lc -lposix4 -lm -lrt -lxerces-c -licuuc -lCrun -lCstd -lpe -lsg -lsde
The following illustrates how to build ArcSDE C API programs on Windows using Visual C++ environment. You will need VC7.0 or higher to build ArcSDE C API programs.
  1. Install ArcSDE C SDK. See Installation guide for more information. In this example, ArcSDE C SDK is installed into the directory C:\ArcGIS\ArcSDE.
     
  2. Check the system PATH. The path to the SDK bin directory (C:\ArcGIS\ArcSDE\bin in this example) must be placed in your system PATH.
     
  3. Start Visual C++ and create an empty “Win32 Console Application” VC++ project.
     
  4. Add your source code to the new VC++ project.
     
  5. Add the ArcSDE C SDK include folder to project “Additional Include Directories”. In this example, add C:\ArcGIS\ArcSDE\include to Additional Include Directories (Project -> Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories)
     
  6. Add the ArcSDE C SDK lib folder to project “Additional Library Directories”. In this example, add C:\ArcGIS\ArcSDE\lib to Additional Library Directories (Project -> Properties -> Configuration Properties -> Linker -> General -> Additional Library Directories)
     
  7. Add sg.lib, sde.lib, pe.lib and icuuc.lib to project “Additional Dependencies” (Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies)
     
  8. Compile source code and build the VC project.
feedback | privacy | legal