Bug 101594

Summary: dlopen cannot open libmyodbc.so
Product: [Retired] Red Hat Linux Reporter: Phillip Lee Thomas <ptho>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: high Docs Contact:
Priority: high    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-08-06 22:57:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Phillip Lee Thomas 2003-08-04 15:39:18 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3.1) Gecko/20030530

Description of problem:
Cannot open libmyodbc.so using dlopen()
Worked under RedHat 8

Test program: 

# compile: gcc -o z -o z.c -ldl
#include <stdio.h>
#include "/usr/include/dlfcn.h"
 
int main()
{
   void *v = dlopen("/usr/lib/libmyodbc.so", RTLD_LAZY);
 
   printf("v = %p\n", v);
   exit(0);
}

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Compile above program z.c with -ldl
2. Have tried under several libmyodbc.so versions, include MyODBC-2.50.36 and later.
3.
    

Actual Results:  Null pointer returned.

Expected Results:  address of library

Additional info:

dlopen() works with some other libraries, but my MyODBC library can be loaded,
whether from RedHat site or MySQL site.

Bugzilla reports other dlopen() problems that may be the same or similar.

Comment 1 Jakub Jelinek 2003-08-04 20:40:19 UTC
You should use dlerror function to see why dlopen has not been successful.
After dlopen add if (!v) printf ("dlopen failed with %s\n", dlerror ());

Comment 2 Jakub Jelinek 2003-08-06 22:57:35 UTC
> [ptho@firefly projects]$ ./z
> v = (nil)
> dlopen failed with /usr/lib/libmysqlclient.so.10: symbol errno, version
> GLIBC_2.0 not defined in file libc.so.6 with link time reference

That means /usr/lib/libmysqlclient.so.10 has been built incorrectly.
Dunno what mysql you're using, certainly it doesn't look
like the one provided in RHL9 or its errata (that uses __errno_location
solely).

You should fix it (the fix is making sure there are no extern int errno;
in the sources, instead wherever errno is used #include <errno.h> preceedes
it - standards allow errno to be a macro and in glibc it is, since glibc 2.1.0
days).
As a workaround, you can put LD_ASSUME_KERNEL=2.4.19 or earlier in the environment
and it should for now work.