dbTalk Databases Forums  

autoconf macro for Sybase C/C++ OpenCLient?

comp.databases.sybase comp.databases.sybase


Discuss autoconf macro for Sybase C/C++ OpenCLient? in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
NoSpam
 
Posts: n/a

Default autoconf macro for Sybase C/C++ OpenCLient? - 07-23-2004 , 03:19 PM






I've been using an M4 macro (derived from the one in the sqsh source
package) for some time now but the omission of the ".a" libraries in the
12.5.1 distribution (for Solaris at least) has broken it. Before I go
hacking at it again, I'm curous if anyone else has something more
"mainstream". Is there an accepted procedure for determining compile and
link flags required to use the OCS libraries?

Wouldn't is be nice if Sybase shipped a '.pc' script for use with
pkg-config? Wish in one hand...

Paul



Reply With Quote
  #2  
Old   
Michael Peppler
 
Posts: n/a

Default Re: autoconf macro for Sybase C/C++ OpenCLient? - 07-26-2004 , 02:21 AM






On Fri, 23 Jul 2004 16:19:01 -0400, NoSpam wrote:

Quote:
I've been using an M4 macro (derived from the one in the sqsh source
package) for some time now but the omission of the ".a" libraries in the
12.5.1 distribution (for Solaris at least) has broken it. Before I go
hacking at it again, I'm curous if anyone else has something more
"mainstream". Is there an accepted procedure for determining compile and
link flags required to use the OCS libraries?
What information is missing when the .a files aren't available?

IIRC the sqsh macro only looks at the .a file to find the OCS version, and
from there determines whether to include the -ltli library in the link
(OCS 10x needs this, OCS 11.x and later does not.)

You could replace this version check with something like running isql -v
and parsing that.

Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler (AT) peppler (DOT) org http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.peppler.org/resume.html



Reply With Quote
  #3  
Old   
NoSpam
 
Posts: n/a

Default Re: autoconf macro for Sybase C/C++ OpenCLient? - 07-26-2004 , 10:09 AM



"Michael Peppler" <mpeppler (AT) peppler (DOT) org> wrote


The "Man" himself! I was considering dropping a note directly to you but
opted for the newsgroup instead. Got the best of both. Cool

Quote:
What information is missing when the .a files aren't available?
If I'm reading it correctly, the AC_SYBASE_ASE macro in the aclocal.m4 for
sqsh-2.1 is looking for each .a (blk, cs, ct, comn, (syb)tcl, intl, and
tds). For each it finds, it's adding "-lfoo" to SYBASE_LIBS. Mine does the
same and find's nothing with 12.5.1 on Solaris.

Here's a clip of what I threw together for now:

<<<<BEGIN>>>>
if test "${enable_debug+set}" = "set"
then
SYBASE_LIBDIR="$SYBASE_OCS/devlib"
else
SYBASE_LIBDIR="$SYBASE_OCS/lib"
fi

if test "${enable_64bit+set}" = "set"
then
SYB64='64'
else
SYB64=''
fi

AC_MSG_CHECKING(sybase libs)
SYBASE_LIBS_STATIC=
SYBASE_LIBS_SHARED=
SYBASE_LIBS_MT_STATIC=
SYBASE_LIBS_MT_SHARED=
for SYBLIB in blk ct cs sybtcl tcl comn intl tds insck
do
if test -f $SYBASE_LIBDIR/lib${SYBLIB}${SYB64}.a
then
SYBASE_LIBS_STATIC="$SYBASE_LIBS_STATIC
$SYBASE_LIBDIR/lib${SYBLIB}${SYB64}.a"
elif test -f $SYBASE_LIBDIR/lib${SYBLIB}${SYB64}.so
then
SYBASE_LIBS_STATIC="$SYBASE_LIBS_STATIC -l${SYBLIB}${SYB64}"
fi
if test -f $SYBASE_LIBDIR/lib${SYBLIB}${SYB64}.so
then
SYBASE_LIBS_SHARED="$SYBASE_LIBS_SHARED -l${SYBLIB}${SYB64}"
fi

if test -f $SYBASE_LIBDIR/lib${SYBLIB}_r${SYB64}.a
then
SYBASE_LIBS_MT_STATIC="$SYBASE_LIBS_MT_STATIC
$SYBASE_LIBDIR/lib${SYBLIB}_r${SYB64}.a"
elif test -f $SYBASE_LIBDIR/lib${SYBLIB}_r${SYB64}.so
then
SYBASE_LIBS_MT_STATIC="$SYBASE_LIBS_MT_STATIC -l${SYBLIB}_r${SYB64}"
fi
if test -f $SYBASE_LIBDIR/lib${SYBLIB}_r${SYB64}.so
then
SYBASE_LIBS_MT_SHARED="$SYBASE_LIBS_MT_SHARED -l${SYBLIB}_r${SYB64}"
fi
done
unset SYBLIB
unset SYB64
AC_MSG_RESULT($SYBASE_LIBS_SHARED)
AC_MSG_CHECKING(sybase OS libs)
case "${host_os}" in
linux*)
SYBASE_OS_LIBS="-ldl -lm";;
sunos*)
SYBASE_OS_LIBS="-lm";;
solaris*)
SYBASE_OS_LIBS="-lnsl -ldl -lm";;
*)
SYBASE_OS_LIBS="-lm -ldl";;
esac
AC_MSG_RESULT($SYBASE_OS_LIBS)
AC_MSG_CHECKING(which sybase libs to use)
if echo $LIBS | grep '\-lpthread' >/dev/null 2>&1
then
if test "$with_static" = "yes"
then
SYBLIBS="$SYBASE_LIBS_MT_STATIC $SYBASE_NET_LIBS_MT"
AC_MSG_RESULT(thread-safe static)
else
SYBLIBS="$SYBASE_LIBS_MT_SHARED $SYBASE_NET_LIBS_MT"
AC_MSG_RESULT(thread-safe shared)
fi
else
if test "$with_static" = "yes"
then
SYBLIBS="$SYBASE_LIBS_STATIC SYBASE_NET_LIBS"
AC_MSG_RESULT(standard static)
else
SYBLIBS="$SYBASE_LIBS_SHARED SYBASE_NET_LIBS"
AC_MSG_RESULT(standard shared)
fi
fi
<<<<END>>>>

It's not right WRT portably detecting a MT environment or it's handling of
the insck. Sybase added a version suffix to the library filename. It's
wrong BTW; they used the release version (i.e. libinsck.so.12.5.1) rather
than it's interface version. Dynamic linking will be hosed with 12.5.2+...
(If you have the right contacts, pass them this;
http://www.gnu.org/software/libtool/manual.html#SEC32)

Quote:
IIRC the sqsh macro only looks at the .a file to find the OCS version, and
from there determines whether to include the -ltli library in the link
(OCS 10x needs this, OCS 11.x and later does not.)

You could replace this version check with something like running isql -v
and parsing that.
Missed that part and will have to do as you suggest. With the version I
have, it's not an issue. We got away from version 10.x years ago.

Let me know if you want my whole macro to tinker with.

Paul




Reply With Quote
  #4  
Old   
Michael Peppler
 
Posts: n/a

Default Re: autoconf macro for Sybase C/C++ OpenCLient? - 07-27-2004 , 05:42 AM



On Mon, 26 Jul 2004 11:09:15 -0400, NoSpam wrote:

Quote:
"Michael Peppler" <mpeppler (AT) peppler (DOT) org> wrote in message
newsan.2004.07.26.07.21.16.114460 (AT) peppler (DOT) org...

The "Man" himself! I was considering dropping a note directly to you but
opted for the newsgroup instead. Got the best of both. Cool

What information is missing when the .a files aren't available?

If I'm reading it correctly, the AC_SYBASE_ASE macro in the aclocal.m4 for
sqsh-2.1 is looking for each .a (blk, cs, ct, comn, (syb)tcl, intl, and
tds). For each it finds, it's adding "-lfoo" to SYBASE_LIBS. Mine does the
same and find's nothing with 12.5.1 on Solaris.
How about just searching for the .so files?

Personally I haven't played much with the autoconf macros. I do have some
perl code that I use, and essentially here's what I do:

First, set the default link line to
-L$SYBASE/$SYBASE_OCS/lib -lct -lcs -ltcl -lcomn -lintl -lblk -ldl -lm

Since we're on 12.x, we can ignore -ltli/-linsck completely - OpenClient
will load the appropriate one at run time.

At this point we need to make a few checks:
1. Are we in threaded mode? If so, add _r to each of the Sybase libs.
2. Are we in 64bit mode? If so, add 64 to the lib names.
3. Linux/MacOS? Change -ltcl to -lsybtcl (note that for 12.5.1 all of the
libs on MacOS are called -lsybXXX...)

This should probably take care of most of the issues. Older Tru-Unix
systems may need -lsdna and/or -ldnet_stub.

Quote:
It's not right WRT portably detecting a MT environment or it's handling of
the insck. Sybase added a version suffix to the library filename. It's
wrong BTW; they used the release version (i.e. libinsck.so.12.5.1) rather
than it's interface version. Dynamic linking will be hosed with 12.5.2+...
(If you have the right contacts, pass them this;
http://www.gnu.org/software/libtool/manual.html#SEC32)
Remember that libinsck, libtli, libskrb and a bunch of others that have
version information aren't supposed to be linked in explicitly. Instead
they are loaded at run-time as required, and the version available at
run-time must match the OCS libs, either the shared libs on the system, or
the static ones linked in.

Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler (AT) peppler (DOT) org http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.peppler.org/resume.html



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.