Issue 465 - ODBC with libiodbc (ODBC lib on UNIX) doesn't work
Summary: ODBC with libiodbc (ODBC lib on UNIX) doesn't work
Status: CLOSED FIXED
Alias: None
Product: Base
Classification: Application
Component: code (show other issues)
Version: 619
Hardware: PC Linux, all
: P4 Trivial (vote)
Target Milestone: ---
Assignee: ocke.janssen
QA Contact: issues@www
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-02-22 19:23 UTC by issues@www
Modified: 2006-05-31 14:29 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
libodbc.so MUST be located in /usr/lib, /usr/local/lib doest not work (BUG) (432 bytes, text/plain)
2003-12-06 14:52 UTC, issues@www
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description issues@www 2001-02-22 19:23:18 UTC
I am using a Linux Debian unstable system with libiodbc installed and pointing
to a local mysql (3.23.33-1) database via libmyodbc 2.50.32-5, libiodbc is
version 2.50.3-2. I manually created a symlink from /usr/lib/libodbc.so to
/usr/lib/libiodbc.so (note the 'i') and this actually works with StarOffice 5.2,
I can use my database just fine. With OpenOffice 619 (and earlier version), when
I click Toold/Data Sources/New Data Source, select ODBC and click on the
"Browse" button, I get a popup with:
"Could not load the program library libodbc.so or is corrupted. The ODBC data
source selection is not available." I tried attaching gdb to the process but the
resulting stack trace was just addresses with (??) - I'm using a provided binary
build (and can't compile OO on my system, it takes days).

I know this is not very helpful right now, if you need anything please contact
me. If not for the fact that SO5.2/ODBC works out of the box (and other clients
using native mysql drivers), I'd not have written this.

My config file for libiodbc: (~/.odbc.ini):
--
[ODBC Data Sources]
friends = mysql
 
[friends]
Driver = /usr/lib/libmyodbc.so
USER   = mcornils
PASSWORD = ****** (I edited this out)
 
[ODBC]
Trace         = 1
TraceAutoStop = 0
TraceFile     = sql.log
-- (~/.odbcinst.ini):
[ODBC Drivers]
mysql = Installed
 
[mysql]
Driver = /usr/lib/libmyodbc.so
PORT   = 3306
SERVER = localhost
Comment 1 issues@www 2001-02-23 15:08:04 UTC
Changing Priority to P4, it's not that important....
Comment 2 issues@www 2001-02-24 16:24:12 UTC
I've downloaded the OO static 619 source, and traced the library loading to a 
function in sal/osl/unx/module.c, line 301:

        if (pszModuleName)
        {
#ifndef NO_DL_FUNCTIONS
                void* pLib = dlopen(pszModuleName, rtld_mode );
#ifdef DEBUG
                if( ! pLib )
                        fprintf( stderr, "osl_loadModule: cannot load module %s
                                         pszModuleName, dlerror() );
#endif
                return ((oslModule)pLib);
#endif
        }
        return NULL;

Is there a precompiled build for my architecture with the DEBUG flag *enabled* 
available? It would be enlightening to see what library name is there after 
the various string conversion routines that precede this, and what kind of 
error dlerror() gives. I'll also try doing the dlopen with the libodbc in one 
a test program and see whether it fails too.

I hope this helps you somewhat! 
-Malte
Comment 3 sander_traveling 2001-02-24 16:53:46 UTC
No, we don't have debug versions of libraries available by default. For one
thing, a debug version of the whole OpenOffice is so big you are just going to
run out of memory unless you have it on the order of ~ 2GB or so. 

If you downloaded teh source you can recompile the library as debug by following
all the build instructions untill the point twhere you would do a dmake (after
bootstrap). Then do:
	cd sal
	rm -rf $INPATH
	dmake debug="true"

the library built will be with bith debug defined to true and with debug symbols
so you will be able to see where and what goes amiss.
Comment 4 issues@www 2001-02-24 18:17:00 UTC
Thanks for your comments Sander, I will try to free some (*cough*) hard drive
space and compile the beastie :), though this could take a day or two...

In the meantime, I've written a small test program, and compiled with gcc-2.95.3
and the -ldl flag, it works as it should:
--cut--
#include <stdio.h>
#include <dlfcn.h>
 
int main() {
        void *pLib = NULL;
 
        printf("Now attempting to link to libodbc.so...\n");
        pLib = dlopen("libodbc.so", RTLD_NOW);
 
        if (pLib == NULL) /* should be equivalent to: if (!pLib) */
                printf("cannot load libodbc.so with error:\n%s\n",
                         dlerror() );
        else {
                printf("loading libodbc.so succeeded!\n");
                printf("dlclose gave back: %d\n", dlclose(pLib));
        }
 
        return;
}
--cut--

The output:
--
mcornils@wh36-b407:/usr/home/mcornils/dev/c$ ./a.out
Now attempting to link to libodbc.so...
loading libodbc.so succeeded!
dlclose gave back: 0
mcornils@wh36-b407:/usr/home/mcornils/dev/c$
--
hmm, strange. Well, I hope I can use the output from the debug build, otherwise
I'll have to dig deeper in /dba/dbaccess/source/ui/dlg, especially the various
OOdbc* classes...

Thanks so far!
-Malte
Comment 5 sander_traveling 2001-02-24 18:23:05 UTC
the wise thing probably is to make a copy of libsal in the openoffice program
directory, recompile *only* sal  (takes around  10 minutes at most) and then
copy the new, debug version of libsal to teh program directory and start the
program under a debugger. 
Comment 6 issues@www 2001-02-24 18:33:23 UTC
> the wise thing probably is to make a copy of libsal in the openoffice program
> directory, recompile *only* sal  (takes around  10 minutes at most) and then
> copy the new, debug version of libsal to teh program directory and start the
> program under a debugger.

ahh, after I read the build requirements (3 Gig hdd space) I was rather sad that
this bug would have to wait until I bought a new drive.. That problem out of the
way, I'll try to do this now. If I encounter further problems, I'll let you know
by adding further comments here (if that is acceptable).

Thanks!

-Malte
Comment 7 sander_traveling 2001-02-24 18:40:56 UTC
Actually, general build issues are better discussed in the
dev@tools.openoffice.org list. See also 
	http://www.openoffice.org/dev_docs/source/build_linux.html
for general build docs for linux.
Comment 8 dirk.grobler 2001-02-27 18:59:49 UTC
Dirk: Ocke is properally the best who can help you. Malte if you need some 
additional help for fixing this bug, please contact Ocke.
Comment 9 dirk.grobler 2001-02-27 19:02:05 UTC
Dirk: Ocke is properally the best who can help you. Malte if you need some 
additional help for fixing this bug, please contact Ocke.
Comment 10 dirk.grobler 2001-02-27 19:04:42 UTC
Ocke is reponsible for that part of code.
Comment 11 ocke.janssen 2001-02-28 14:11:11 UTC
with a link odbclib.so -> libodbc.so the connection should work
Comment 12 issues@www 2001-02-28 20:48:13 UTC
Hi Ocke, thanks for the suggestion;
I've tried symlinking libodbc.so to odbclib.so, but I still get the same error.
(BTW: is namelib.so the standard under Solaris, or why is this different to
SO5.2?) My test program works fine:
--
#include <stdio.h>
#include <dlfcn.h>
 
int main() {
        void *pLib = NULL;
 
        printf("Now attempting to link to odbclib.so...\n");
        pLib = dlopen("odbclib.so", RTLD_NOW);
 
        if (pLib == NULL) /* equivalent to: if (!pLib) */
                printf("cannot load odbclib.so with error:\n%s\n",
                         dlerror() );
        else {
                printf("loading odbclib.so succeeded!\n");
                printf("dlclose gave back: %d\n", dlclose(pLib));
        }
 
        return;
}
--
Output:
mcornils@wh36-b407:/usr/home/mcornils/dev/c$ ./a.out
Now attempting to link to odbclib.so...
loading odbclib.so succeeded!
dlclose gave back: 0
mcornils@wh36-b407:/usr/home/mcornils/dev/c$
--

I will try debugging this following your advice, but it will be a few days; if
you have any other ideas not involving a debug build which I will do then, I'd
love to hear them though :-)

-Malte #8-)

Comment 13 issues@www 2001-05-06 13:04:12 UTC
I have finally (!) succeeded in making a debug build of the sal library, and I
guess I have found the problem. Opening the library gives:
--cut!--
osl_loadModule : lib to load : [libodbc.so]
osl_getsymbol: cannot get Symbol SQLAllocHandle for reason:
/home/mcornils/openoffice60/program/libsal2.so: undefined symbol: SQLAllocHandle
osl_getsymbol: cannot get Symbol SQLFreeHandle for reason:
/home/mcornils/openoffice60/program/libsal2.so: undefined symbol: SQLFreeHandle
osl_getsymbol: cannot get Symbol SQLSetEnvAttr for reason:
/home/mcornils/openoffice60/program/libsal2.so: undefined symbol: SQLSetEnvAttr
--cut!--

and a search on the first one reveals that it's an ODBC 3.0 function. However,
my ODBC library (libiodbc) does not support ODBC 3.0 functions, only ODBC 2.5. A
search for the SQLAllocHandle symbol fails, while lots of older ODBC functions
are there. So this might a) be a bug in OO's ODBC handling that breaks
backwards-compatibility [1] or b) mean that ODBC 3.0 is simply needed in
OpenOffice and I need to either fix up libiodbc (now if I had a clue :)) or get
a different ODBC library like unixodbc.

It would be cool if it were a) and you could fix the problem somehow; in any
case I'd be really grateful for your take on this.

Thanks for enduring for so long,

Yours Malte #8-)

[1] since I couldn't find any reference on OO's requirements being ODBC 3.0, I
have also reopened this issue.
Comment 14 issues@www 2001-05-06 13:39:34 UTC
Oh, and BTW, the unstable development version of libiodbc (3.0.4beta) which I'm
using now works. Cool.

-Malte #8-)
Comment 15 ocke.janssen 2001-05-07 08:51:06 UTC
Hi,
now the dba sites say that ODBC version 3.0 is supported.

Regards,
Ocke
Comment 16 issues@www 2001-07-22 14:18:58 UTC
Created attachment 412 [details]
libodbc.so MUST be located in /usr/lib, /usr/local/lib doest not work (BUG)
Comment 17 ocke.janssen 2002-05-24 10:40:09 UTC
Hi,

fixed in OOo 1.0

Ocke
Comment 18 ocke.janssen 2002-10-07 08:38:35 UTC
Closing now.
Comment 19 hans_werner67 2004-02-02 12:51:39 UTC
change subcomponent to 'none'