[m-users.] ODBC library

Julien Fischer jfischer at opturion.com
Sun Jan 16 16:35:39 AEDT 2022


Hi Volker,

On Sat, 15 Jan 2022, Volker Wysk wrote:

> I'm trying to build a program which uses the ODBC library. I've played
> around, but couldn't get mmc to link the program. It doesn't work with the
> odbc_test program in extras/odbc, even though it had worked before I
> installed the Mercury ODBC library:
>
>
> desktop /usr/local/src/mercury-srcdist-rotd-2022-01-13/extras/odbc $ \
> mmc --make odbc_test -lodbc  --cflag "-DMODBC_UNIX" --cflag "-DMODBC_MYSQL"

I think there are two things happening here:

1)

The above command is trying to link against an installed version of the
Mercury ODBC library, right?

If so, it's missing the options to tell the Mercury compiler to use the
Mercury ODBC library, the --ml and --mld options.  The following command
line options work on my system:

     --cflag "-DMODBC_UNIX"
     --cflag "-DMODBC_MYSQL"
     --ml odbc
     --mld <odbc-lib-install-prefix>/lib/mercury
     -odbc
     -lpthread
     -ldl

2) Are you trying to compiler odbc_test inside the directory
extras/odbc?  If so, the compiler is likely getting confused by
the presence of the module odbc.m in the same directory (as well 
as in the installed library).

> Making odbc_test
> ** Error making `odbc_test'.
> /usr/bin/ld: Mercury/os/odbc.o: in function `odbc_do_cleanup_statement':
> odbc.c:(.text+0x3317): undefined reference to `SQLFreeStmt'
> /usr/bin/ld: Mercury/os/odbc.o: in function `odbc_check.part.0':
> odbc.c:(.text+0x3808): undefined reference to `SQLError'
> /usr/bin/ld: Mercury/os/odbc.o: in function `odbc_transaction_c_code':
> odbc.c:(.text+0x3983): undefined reference to `SQLTransact'
> /usr/bin/ld: odbc.c:(.text+0x3a13): undefined reference to `SQLTransact'
> /usr/bin/ld: odbc.c:(.text+0x3a5e): undefined reference to `SQLTransact'
> /usr/bin/ld: Mercury/os/odbc.o: in function `odbc_get_data_in_one_go':
> odbc.c:(.text+0x3bd1): undefined reference to `SQLGetData'
> /usr/bin/ld: Mercury/os/odbc.o: in function `odbc_get_data_in_chunks':
> odbc.c:(.text+0x3ca0): undefined reference to `SQLGetData'
> /usr/bin/ld: Mercury/os/odbc.o: in function `odbc_do_get_data':
> odbc.c:(.text+0x3e0a): undefined reference to `SQLGetData'
> /usr/bin/ld: Mercury/os/odbc.o: in function `odbc_do_get_data_sources':
> ... error log truncated, see `odbc_test.err' for the complete log.
>
>
> "mmake depend ; mmake" doesn't work either. The error messages seem to
> indicate the same problem.
>
> It looks like the UnixODBC library is missing, not getting linked... Might
> it be a name clash, since the UnixODBC library has the same name
> "libodbc.so" as the Mercury ODBC library which is installed in
> /usr/local/lib/mercury/lib/... ?

Are you compiling with --mercury-linkage static?  I get the same with
that, but not with --mercury-linkage shared.

I will rename the Mercury library to libmercury_odbc, which should
avoid that problem (and will hopefully assist in reducing confusion).

Julien.


More information about the users mailing list