This section gives information on libraries, linking, and header files.
Client-Library and Server-Library now support dynamic
loading of
Net-Library™, directory, and security drivers. This change
affects the way you link Client-Library, Server-Library, and Embedded SQL applications.
You no longer need to explicitly link the following object files with your applications:
Sybase Net-Library drivers
Sybase directory drivers
Sybase 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 the UNIX operating system.
Table 4-1 shows the commands for compiling and linking Embedded SQL/C applications using static libraries.
Platform |
Command |
---|---|
Sun Solaris 2.x |
/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 |
Sun Solaris 10 x64 (Opteron) 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 RS/6000 |
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 9000 (8xx) |
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 Itanium |
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 |
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 on POWER |
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 AMD64 (Opteron)/ EM64T |
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 |
---|---|
Sun Solaris 2.x |
/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 |
Sun Solaris 10 x64 (Opteron) 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 RS/6000 |
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 9000 (8xx) |
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 Itanium |
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 |
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 on POWER |
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 AMD64 (Opteron)/ EM64T |
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 |
---|---|
Sun Solaris 2.x |
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 |
Sun Solaris 10 x64 (Opteron) 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 RS/6000 |
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 9000 (8xx) |
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 Itanium |
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 |
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 on POWER |
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 AMD64 (Opteron)/EM64T |
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 in
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 non-threaded 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. For more information about building and linking a 64-bit application, see the sybopts.sh script available in the $SYBASE/$SYBASE_OCS/sample/esqlc directory.
For 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-UX will 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 will be able to 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 man page for more information.