undefined symbol issue related to sharing a global among source files

From: Date: Thu, 13 May 2010 18:37:37 +0000
Subject: undefined symbol issue related to sharing a global among source files
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-7225@lists.php.net to get a copy of this message
Hello all, I'm quite new to extension writing, have been through multiple tutorials, and am now attempting to create an extension that exposes a class Graph and a class Category. Graph needs to have a graph->getCategory() method which returns a Category instance into the userspace. I just want to be able to do this: <?php $g = new Graph(); $cat = $g->getCategory(); ?> My problem: I can get my extension to compile, but when I attempt to instantiate either Graph or Category, I get the error: Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/getgraph.so' - /usr/local/lib/php/extensions/getgraph.so: undefined symbol: category_object_handlers in Unknown on line 0 Can someone tell me more about what this error means, or even better, what I'm doing wrong? Here's more info on my code: - Graph and the extension glue (MINIT functions, etc.) are defined in php_getgraph.cpp + php_getgraph.h. - Category is defined in php_category.cpp + php_category.h. - I'm exposing the Graph and Category classes in the MINIT function: PHP_MINIT_FUNCTION(getgraph) { zend_class_entry ce_cat; INIT_CLASS_ENTRY(ce_cat, "Category", php_category_functions); category_ce = zend_register_internal_class(&ce_cat TSRMLS_CC); category_ce->create_object = category_create_handler; memcpy(&category_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); category_object_handlers.clone_obj = NULL; zend_class_entry ce_graph; INIT_CLASS_ENTRY(ce_graph, "Graph", php_getgraph_functions); graph_ce = zend_register_internal_class(&ce_graph TSRMLS_CC); graph_ce->create_object = graph_create_handler; memcpy(&graph_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); graph_object_handlers.clone_obj = NULL; return SUCCESS; } - category_ce and category_object_handlers are declared in php_category.h: extern zend_class_entry *category_ce; extern zend_object_handlers category_object_handlers; - both php_category.cpp and php_getgraph.h #include "php_category.h" If I'm leaving out some important info, please let me know and I'll provide it. Thanks very much in advance for *any* feedback you can offer. Sincerely, John

« previous php.pecl.dev (#7225) next »