cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Static library for Sybase CT library (Windows, Linux)

Former Member
0 Likes
1,892

Dear Friends,

I am upgrading a C++ application to read data from Sybase ASE (15.7) database on Windows and Linux.

After going thru Sybase manuals, I found that open client (CT) library can be used to communicate with ASE DB server.

Is this library available for static linking into C++ executable? Or is the CT library source code available for compiling into the executable?

A Sybase page (http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc35455.1500/html/ocspw95/o...) refers to libsybct.lib, which is an import lib to load corresponding dll, but I did not find more details on static version of this library.

Thanks in advance for your help and time

Best Regards.

View Entire Topic
Former Member
0 Likes

Hi,

As Simon mentions for Linux/UNIX both static and shared libs are provided.

Your best bet is to become familiar with the samples. On Linux, for example, check out the $SYBASE/OCS-15_0/sample/ctlibrary directory

Check the sybopts.sh file for sample compile/link lines for various platforms and whether you want threaded or non-threaded. You start out deciding if you want non-threaded or threaded.

Keep in mind I am doing this with the SDK 15.7 x64 version on Linux (32 bit libraries install only with the non threaded static/shared libs, for threaded only the shared libs are included).

So, for 64-bit if you want to build static non-threaded:

setenv SYBPLATFORM linux64

I modify sybopts.sh:

        linuxamd64 | linux64)

                        CC="gcc";

                        CFLAGS="-m64 -g -DSYB_LP64 -Wall -Wformat=2 -Wl,-Bstatic";

                        BLKLIB="-lsybblk64"; SRVLIB="-lsybsrv64"; CTLIB="-lsybct64";

                        COMLIBS="-lsybtcl64 -lsybcs64 -lsybcomn64 -lsybintl64 -lsybunic64";

                        SYSLIBS="-Wl,-Bdynamic -ldl -lnsl -lm" ;;

Then run

make firstapp

ldd firstapp

        libdl.so.2 => /lib64/libdl.so.2 (0x0000003e3ce00000)

        libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003e40a00000)

        libm.so.6 => /lib64/libm.so.6 (0x0000003e3ca00000)

        libc.so.6 => /lib64/libc.so.6 (0x0000003e3c600000)

        /lib64/ld-linux-x86-64.so.2 (0x0000003e3c200000)

[I leave the system libs as dynamic]

If I run the make with modified sybopts.sh (removing -Wl,-Bstatic)

ldd firstapp:

        libsybct64.so => /sybase/ocs/syb157/OCS-15_0/lib/libsybct64.so (0x00002aaaaaaad000)

        libsybtcl64.so => /sybase/ocs/syb157/OCS-15_0/lib/libsybtcl64.so (0x00002aaaaad48000)

        libsybcs64.so => /sybase/ocs/syb157/OCS-15_0/lib/libsybcs64.so (0x00002aaaaaf6f000)

        libsybcomn64.so => /sybase/ocs/syb157/OCS-15_0/lib/libsybcomn64.so (0x00002aaaab183000)

        libsybintl64.so => /sybase/ocs/syb157/OCS-15_0/lib/libsybintl64.so (0x00002aaaab441000)

        libsybunic64.so => /sybase/ocs/syb157/OCS-15_0/lib/libsybunic64.so (0x00002aaaab64a000)

        libdl.so.2 => /lib64/libdl.so.2 (0x0000003e3ce00000)

        libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003e40a00000)

        libm.so.6 => /lib64/libm.so.6 (0x0000003e3ca00000)

        libc.so.6 => /lib64/libc.so.6 (0x0000003e3c600000)

        /lib64/ld-linux-x86-64.so.2 (0x0000003e3c200000)

On the threaded side, similar deal. I actually make a copy of the section (I think I made additions to accomodate my gcc compiler on the linux machine I use):

        nthread_linuxamd64 | nthread_linux64)

                        CC="cc";

                        CFLAGS="-m64 -g -DSYB_LP64 -D_REENTRANT -Werror -Wall -Wformat=2";

                        BLKLIB="-lsybblk_r64"; SRVLIB="-lsybsrv_r64"; CTLIB=-lsybct_r64;

                        COMLIBS="-lsybtcl_r64 -lsybcs_r64 -lsybcomn_r64 -lsybintl_r64 -lsybunic64";

                        SYSLIBS="-Wl,-Bdynamic -ldl -lpthread -lnsl -lm" ;;

I create a new section:

        nthread_linuxamd64_static | nthread_linux64_static)

                        CC="cc";

                        CFLAGS="-m64 -g -DSYB_LP64 -D_REENTRANT -Werror -Wall -Wformat=2 -Wl,-Bstatic";

                        BLKLIB="-lsybblk_r64"; SRVLIB="-lsybsrv_r64"; CTLIB=-lsybct_r64;

                        COMLIBS="-lsybtcl_r64 -lsybcs_r64 -lsybcomn_r64 -lsybintl_r64 -lsybunic64";

                        SYSLIBS="-Wl,-Bdynamic -ldl -lpthread -lnsl -lm" ;;

setenv SYBPLATFORM nthread_linux64_static

make firstapp

ldd firstapp

        libdl.so.2 => /lib64/libdl.so.2 (0x0000003e3ce00000)

        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003e3d200000)

        libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003e40a00000)

        libm.so.6 => /lib64/libm.so.6 (0x0000003e3ca00000)

        libc.so.6 => /lib64/libc.so.6 (0x0000003e3c600000)

        /lib64/ld-linux-x86-64.so.2 (0x0000003e3c200000)

I don't know if it is advantageous to build static other than for deployment reasons, however, if you need to update client library you must rebuild the application to use the new libraries. On dynamic builds an update of client library provides access to the new libraries.

For Windows, I don't think there really is a concept of static libraries since you use DLLs (as Simon points out). You do link to the libsybct.lib, etc in your application project but the application accesses the DLLs during runtime. I don't think we provide a static windows library for client library functions.

Cheers,

-Paul

Former Member
0 Likes

Hi Friends

Guidelines provided by you are really great and helpful.

After comparing programming with ODBC and Sybase native (CT) libraries, I understood that native libs would require more configuration than ODBC. Also, I already have ODBC framework incorporated for MSSQL in our application.

I have decided to use ODBC for accessing ASE server.

Many thanks for your guidance.

Best Regards