[erlang-questions] : ODBC library - link check failed on mac leopard

Geoff Cant nem@REDACTED
Wed Jun 25 20:13:35 CEST 2008


"Peter Lemenkov" <lemenkov@REDACTED> writes:

> 2008/6/25 wenew zhang <wenewboy@REDACTED>:
>> error below:do you user mac now?
>
> Yes, I'm a mac user.
>
>> so i think macport doesn't add the odbc suports in erlang,
>
> Exactly.
>
> auriga:~ petro$ erl
> Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] [hipe]
> [kernel-poll:false]
>
> Eshell V5.6.2  (abort with ^G)
> 1> odbc:start().
> ** exception error: undefined function odbc:start/0
> 2>

This is a problem I tend to fixup in macports - the odbc application
needs to link (and link check) against libiodbc not libodbc. Libiodbc is
shipped as part of Mac OS X (Tiger and Leopard I'm sure of) and provides
the exact same API as libodbc.

It'd be nice if there was a special case for darwin/macos in the
configure script that would linkcheck against iodbc. Something like:

diff --git a/lib/odbc/configure.in b/lib/odbc/configure.in
index 114f86a..d1df895 100644
--- a/lib/odbc/configure.in
+++ lib/odbc/configure.in
@@ -136,6 +136,16 @@ have_odbc_lib=no
 	
 AC_SUBST(TARGET_FLAGS)
     case $host_os in
+        darwin*)
+                TARGET_FLAGS="-DUNIX"
+                AC_CHECK_LIB(pthread, pthread_create,
+			    [AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if you have the pthread library (-lpthread).])
+			     LIBS="$LIBS -lpthread"
+			     have_pthread_lib=yes])
+                ODBC_LIB=-L"/usr/lib"
+                ODBC_INCLUDE="-I/usr/lib/include"
+	        AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -liodbc" odbc_lib_link_sucess=yes])
+            ;;
         win32|cygwin)
 		TARGET_FLAGS="-DWIN32"
 		AC_CHECK_LIB(ws2_32, main)

This was prepared for R12B-2 and works :

1> application:start(odbc).
ok

Available as a git patch at (http://git.erlang.geek.nz/?p=erlang-otp.git;a=commit;h=5d71d8f6c8a5743422c9d9104574d7fa4945a912).

Maybe something like this could be rolled into R12B-4 ?

Cheers,
-- 
Geoff Cant




More information about the erlang-questions mailing list