[getdns-users] SWIG, PHP, and Undefined Functions

Hollenbeck, Scott shollenbeck at verisign.com
Mon Feb 2 12:14:33 UTC 2015


I've been playing around with SWIG (http://www.swig.org/) in an attempt to create PHP language bindings for getdns. I've been able to build a PHP extension, but when I try to use it I get an "undefined function" error:

Fatal error: Call to undefined function getdns_context_create() in /path/getdns.php on line 679

These is the result of print_r(get_extension_funcs("getdns")):

Array
(
    [0] => getdns_address
    [1] => getdns_address_sync
    [2] => getdns_hostname
    [3] => getdns_hostname_sync
    [4] => getdns_service
    [5] => getdns_service_sync
    [6] => getdns_general
    [7] => getdns_general_sync
    [8] => getdns_dict_destroy
    [9] => swig_getdns_alter_newobject
    [10] => swig_getdns_get_newobject
)

Here's some of what nm reports (note the undefined symbols):

sah at sah-vb:~/projects/getdns/src/php$ nm getdns.so|grep context
                 U getdns_context_create
                 U getdns_context_create_with_extended_memory_functions
                 U getdns_context_create_with_memory_functions
                 U getdns_context_destroy

My swig interface file:

%module getdns
%{
/* Put headers and other declarations here. */
#include <getdns.h>
#include <getdns_extra.h>
%}

%include <getdns.h>
%include <getdns_extra.h>

Here's how I'm building the extension:

swig -php -outcurrentdir -I/usr/local/include/getdns ../getdns.i
gcc `php-config --includes` -fPIC -c -I/usr/local/include/getdns getdns_wrap.c
gcc getdns_wrap.o -o getdns.so -shared -L/usr/local/lib -lgetdns

I wrote a small C program that works just fine using the same getdns shared library. I'm pretty sure I'm missing something obvious in the way I set up my SWIG interface and the code it produces, but I'm a SWIG noob - what did I miss?

Scott




More information about the Users mailing list