# library constructor not called from php extension

- Thread: https://externals.io/message/14523
- Original archive: https://news-web.php.net/php.internals/14523
- Started by Thomas Boehne on 2005-02-02T13:43:23+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14523 — Thomas Boehne — 2005-02-02T13:43:23+00:00

URL: https://externals.io/message/14523#14523

Hello PHP developers, 

I have a just written a PHP-Extension as described in the
documentation. I am using PHP 4.3.10. Configure (--with-libadwin),
compiling and linking work fine, this is what ldd shows (libadwin.so.4
is the function used by my extension):

thomasb:~/php-4.3.10 1$ ldd ./sapi/cgi/php
        libcrypt.so.1 => /lib/tls/libcrypt.so.1 (0xb7fa4000)
        libadwin.so.4 => /usr/local/adwin//lib/libadwin.so.4 (0xb7f79000)
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7f6a000)
        libresolv.so.2 => /lib/tls/libresolv.so.2 (0xb7f58000)
        libm.so.6 => /lib/tls/libm.so.6 (0xb7f36000)
        libdl.so.2 => /lib/tls/libdl.so.2 (0xb7f33000)
        libnsl.so.1 => /lib/tls/libnsl.so.1 (0xb7f1f000)
        libc.so.6 => /lib/tls/libc.so.6 (0xb7dea000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fea000)

Calling libadwin-functions does basically work from my php-extension,
but the problem is that the library constructor of libadwin is not
executed. I have never had such a problem with other programs that
were linked against that library. The constructor in the library is
defined like this:

void __attribute__ ((constructor)) my_init(void) {

My current workaround is to manually call the initialization
functions, but for customer releases I must rely on the constructor
being used.

I am not sure if the problem exists in php5 as well, but I could check
if someone is interested.

Any ideas?

Thomas

-- 
Jäger Computergesteuerte Messtechnik GmbH
Thomas Böhne
Rheinstraße 2-4
64653 Lorsch
Germany
Phone: +49-6251-9632-0
