Re: PDO problems with OSX
| From: | Mika Tuupola | Date: | Mon, 11 Oct 2004 19:52:53 +0000 |
| Subject: | Re: PDO problems with OSX | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-1446@lists.php.net to get a copy of this message | ||
On Sun, 10 Oct 2004, Wez Furlong wrote:
> On Sun, 10 Oct 2004 01:09:13 +0300 (EEST), Mika Tuupola
> <tuupola@appelsiini.net> wrote:
> > dyld: php Undefined symbols:
> > _php_pdo_register_driver
> > Trace/BPT trap
>
> You're definitely loading PDO before PDO_SQLITE ?
I think I have atleast some kind of clue on the problem.
Since I dont speak C, fixing it is beyond my capabilities.
However the problem seems to originate from the fact that
on OSX symbol that is passed to dlsym requires a leading
underscore. Excerpts from dlsym manual page in the end.
Looking at some source code (apache_1.3.29/src/os/unix/os.c)
Apache seems to get around this by the following:
-cut-
#elif defined(DLSYM_NEEDS_UNDERSCORE)
char *symbol = (char*)malloc(sizeof(char)*(strlen(symname)+2));
void *retval;
sprintf(symbol, "_%s", symname);
retval = dlsym(handle, symbol);
free(symbol);
return retval;
-cut-
ZendEngine seems to have the following:
http://chora.php.net/co.php/ZendEngine2/zend.h
-cut-
# if defined(DLSYM_NEEDS_UNDERSCORE)
# define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
# else
-cut-
Searching google for DLSYM_NEEDS_UNDERSCORE reveals a lot
of similar code.
If I am on correct track, maybe someone fluent with C can
actually fix the OSX problem. Anyway here is the manual
excerpt:
-cut-
NAME
dlopen, dlsym, dlerror, dlclose - programmatic interface to the
dynamic linker
...
See the note about underscores and C symbols, dlsym() may or may
not need to be called with an underscore prepended to the C
function name, depending upon how this package was configured.
...
In darwin objects, C symbols have an underscore prepended to the
symbol name. So, the function getpid() ends up in the object file
as _getpid Most code assumes that there is no underscore and
calls dlsym() with symbol as "getpid" which would fail to find the
symbol.
Depending on how the dlcompat package was built, the dlsym()
function may, or may not, automatically prepend an underscore to
the passed symbol to compensate for this. In this case calling
dlsym() with symbol as "getpid" does indeed find the _getpid
symbol.
...
BUGS
The underscore or not issue is unnecessarily confusing.
-cut-
--
Mika Tuupola http://www.appelsiini.net/~tuupola/