[m-users.] ODBC library
Volker Wysk
post at volker-wysk.de
Mon Jan 17 02:57:59 AEDT 2022
Am Sonntag, dem 16.01.2022 um 16:35 +1100 schrieb Julien Fischer:
> 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?
Yes.
> 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
They don't work on my system:
desktop /usr/local/src/mercury-srcdist-rotd-2022-01-13/extras/odbc $ \
mmc --make odbc_test -lodbc --cflag "-DMODBC_UNIX" \
--cflag "-DMODBC_MYSQL" --ml odbc \
--mld /usr/local/lib/mercury-20.06.1/lib/mercury/
/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.
After I uninstalled the odbc library, with:
desktop /usr/local/lib/mercury-20.06.1 $ find -name '*odbc*'|xargs rm
... this worked again:
mmc --make odbc_test -lodbc --cflag "-DMODBC_UNIX" --cflag "-DMODBC_MYSQL"
Same for the short ODBC test program in my project.
>
> 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
> >
> >
> > 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 haven't selected either static or shared.
> I will rename the Mercury library to libmercury_odbc, which should
> avoid that problem (and will hopefully assist in reducing confusion).
You haven't done that yet, right now, in Git. I'd like to volunteer to do
this. All the prefixes "odbc." need to be changed to "mercury_odbc.". Okay?
Cheers, Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20220116/41932c9c/attachment.sig>
More information about the users
mailing list