Use libraries, linking, and header files to compile and link an Embedded/SQL C application.
Client-Library and Server-Library support dynamic loading of Net-Library™, directory, and security drivers. You do not need to explicitly link these Sybase object files with your applications:
Net-Library drivers
Directory drivers
Security drivers
The following tables list the general forms of the commands for compiling and linking Embedded SQL/C applications on Sybase supported platforms running on UNIX.
Table 4-1 shows the commands for compiling and linking Embedded SQL/C applications using static libraries.
Platform |
Command |
---|---|
Solaris SPARC 32-bit and 64-bit |
/opt/SUNWspro/bin/cc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Bstatic -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -Bdynamic -lnsl -ldl -lm -lsocket -o program |
Solaris x86-64 32-bit and 64-bit |
/opt/SunStudio10/SUNWspro/bin/cc -xtarget=opteron -xarch=amd64 -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Bstatic -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -Bdynamic -lnsl -ldl -lm -lsocket -o program |
IBM AIX RS/6000 32-bit and 64-bit |
xlc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-Bstatic -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -lm -o program |
HP HP-UX PA-RISC 32-bit and 64 bit |
cc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-a,archive -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -Wl,-a,default -lcl -lm -lBSD -ldld -Wl, -E, +s -o program |
HP HP-UX Itanium 32-bit and 64-bit |
cc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-a,archive -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -Wl,-a,default -lcl -lm -lBSD -ldld -Wl, -E, +s -o program |
Linux x86 32-bit |
cc -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-Bstatic -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -Wl,-Bdynamic -ldl -lnsl -lm -o program |
Linux POWER 32-bit and 64-bit |
xlc -q32 -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-Bstatic -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -Wl,-Bdynamic -ldl -lnsl -lm -o program |
Linux x86-64 64-bit |
gcc -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl, -Bstatic -lsybct64 -lsybcs64 -lsybtcl64 -lsybcomn64 -lsybintl64 -lsybunic64 -Wl, -Bdynamic -ldl -lnsl -lm64 -o program |
Table 4-2 shows the commands for compiling and linking Embedded SQL/C applications using debug libraries.
Platform |
Command |
---|---|
Solaris SPARC 32-bit and 64-bit |
/opt/SUNWspro/bin/cc -g -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -lnsl -ldl -lm -lsocket -o program |
Solaris x86-64 32-bit and 64-bit |
/opt/SunStudio10/SUNWspro/bin/cc -xtarget=opteron -xarch=amd64 -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -lnsl -ldl -lm -lsocket -o program |
IBM AIX RS/6000 32-bit and 64-bit |
xlc -g -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -lm -o program |
HP HP-UX PA-RISC 32-bit and 64 bit |
cc -g -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -lcl -lm -lBSD -ldld -o program |
HP HP-UX Itanium 32-bit and 64-bit |
cc -g -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -lcl -lm -lBSD -ldld -o program |
Linux x86 32-bit |
cc -g -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -ldl -lnsl -lm -o program |
Linux POWER 32-bit and 64-bit |
xlc -q32 -g -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -lsybct -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic -ldl -lnsl -lm -o program |
Linux x86-64 64-bit |
gcc -g -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -lsybct64 -lsybcs64 -lsybtcl64 -lsybcomn64 -lsybintl64 -lsybunic64 -ldl -lnsl -lm64 -o program |
Table 4-3 shows the commands for compiling and linking Embedded SQL/C applications using shareable libraries (with dynamic drivers).
Platform |
Command |
---|---|
Solaris SPARC 32-bit and 64-bit |
cc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Bdynamic -lsybct -lsybcs -lnsl -ldl -lm -lsocket -o program |
Solaris x86-64 32-bit and 64-bit |
cc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Bdynamic -lsybct -lsybcs -lnsl -ldl -lm -lsocket -o program |
IBM AIX RS/6000 32-bit and 64-bit |
xlc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-Bdynamic -lsybct -lsybcs -lm -o program |
HP HP-UX PA-RISC 32-bit and 64 bit |
cc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,a,shared_archive -lsybct -lsybcs -lcl -lm -lBSD -o program |
HP HP-UX Itanium 32-bit and 64-bit |
cc -I$SYBASE/$SYBASE_OCS/include -L$SYBASE/$SYBASE_OCS/lib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,a,shared_archive -lsybct -lsybcs -lcl -lm -lBSD -o program |
Linux x86 32-bit |
cc -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-Bdynamic -lsybct -lsybcs -ldl -lnsl -lm -o program |
Linux POWER 32-bit and 64-bit |
xlc -q32 -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-Bdynamic -lsybct -lsybcs -ldl -lnsl -lm -o program |
Linux x86-64 64-bit |
gcc -I$SYBASE/$SYBASE_OCS/include-L$SYBASE/$SYBASE_OCS/devlib gen_program.c $SYBASE/$SYBASE_OCS/include/sybesql.c -Wl,-Bdynamic -lsybct64 -lsybcs64 -ldl -lnsl -lm64 -o program |
The object produced by compiling the sybesql.c file contains
utility routines that are used by Embedded SQL/C
applications. You must link sybesql.o with
every application for the application to work properly.
The link line for an Embedded SQL/C application is identical to that used for a Client-Library application. In the link line, gen_program.c is the generated C file from cpre.
-lsybct represents the linker option to link in the Open Client libraries that your code calls. In addition to -lsybct, you can also specify any or all of the following linker options, in the order shown:
For nonthreaded applications |
For threaded applications |
---|---|
-lsybsrv (for Server-Library routines) |
-lsybsrv_r (for Server-Library routines) |
-lsybblk (for Bulk-Library routines) |
-lsybblk_r (for Bulk-Library routines) |
-lsybct (for Client-Library routines) |
-lsybct_r (for Client-Library routines) |
To build a 64-bit C application, use the -DSYB_LP64 compiler option to ensure that the C compiler generates the correct code. See the sybopts.sh script available in $SYBASE/$SYBASE_OCS/sample/esqlc.
For HP HP-UX system users:
The option -Wl,-a,archive causes the linker to statically link the Sybase libraries. Without it, shared versions of the Sybase libraries are used. In this case, the SH_LIB_PATH environment variable must include $SYBASE/$SYBASE_OCS/lib at runtime, and the application user must have read and execute permission on the libraries in $SYBASE/$SYBASE_OCS/lib.
HP HP-UX does not use the SH_LIB_PATH environment variable at runtime unless the application is linked with the +s linker option. You must use the +s linker options so that the system can find Sybase libraries at runtime. -E is required to prevent undefined-symbol errors when driver libraries are loaded at runtime. See the HP-UX ld.