Comment 5 for bug 867133

Revision history for this message
akaplan (akaplan) wrote :

I've had the same error:
Undefined symbols:
  "_zval_is_true", referenced from:
      _wrap_swig_zorba_api_alter_newobject(int, _zval_struct*, _zval_struct**, _zval_struct*, int)in zorba_apiPHP5_wrap.cxx.o
  "_zend_lookup_class", referenced from:
      SWIG_ZTS_SetPointerZval(_zval_struct*, void*, swig_type_info*, int)in zorba_apiPHP5_wrap.cxx.o
  "__object_init", referenced from:
      SWIG_ZTS_SetPointerZval(_zval_struct*, void*, swig_type_info*, int)in zorba_apiPHP5_wrap.cxx.o
     (maybe you meant: __object_init_ex)
  "__zend_hash_add_or_update", referenced from:
      SWIG_ZTS_SetPointerZval(_zval_struct*, void*, swig_type_info*, int)in zorba_apiPHP5_wrap.cxx.o
  "_php_strtolower", referenced from:
      SWIG_ZTS_SetPointerZval(_zval_struct*, void*, swig_type_info*, int)in zorba_apiPHP5_wrap.cxx.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [swig/php/libzorba_api.so] Error 1

Here's the command-line:
/usr/bin/g++-4.2 -pipe -O2 -I/opt/local/var/macports/build/_Users_andre_MacPorts_textproc_zorba/zorba/work/zorba-2.0.2/build/../include -arch x86_64 -Wall -Wextra -Woverloaded-virtual -Wsign-promo -Winit-self -Wno-unused-parameter -fvisibility=hidden -fno-strict-aliasing -O3 -DNDEBUG -arch x86_64 -isysroot / -mmacosx-version-min=10.6 -bundle -Wl,-headerpad_max_install_names -L/opt/local/lib -arch x86_64 -o libzorba_api.so CMakeFiles/zorba_api.dir/zorba_apiPHP5_wrap.cxx.o ../../src/libzorba_simplestore.2.0.2.dylib -bundle -Wl,-headerpad_max_install_names -Wl,-flat_namespace,-U,_convert_to_boolean,-U,_gc_remove_zval_from_buffer,-U,_zend_throw_exception,-U,_zend_register_long_constant,-U,_zend_get_constant,-U,__zval_copy_ctor_func,-U,__convert_to_string,-U,__estrndup,-U,__efree,-U,__emalloc,-U,__estrdup,-U,__object_init_ex,-U,__zend_get_parameters_array_ex,-U,__zend_list_find,-U,__zval_copy_ctor,-U,_add_property_zval_ex,-U,_alloc_globals,-U,_compiler_globals,-U,_convert_to_double,-U,_convert_to_long,-U,_zend_error,-U,_zend_hash_find,-U,_zend_register_internal_class_ex,-U,_zend_register_list_destructors_ex,-U,_zend_register_resource,-U,_zend_rsrc_list_get_rsrc_type,-U,_zend_wrong_param_count,-U,_zval_used_for_init -lpthread /opt/local/lib/libicuuc.dylib /opt/local/lib/libicui18n.dylib /opt/local/lib/libicudata.dylib /opt/local/lib/libxml2.dylib /opt/local/lib/libxslt.dylib /opt/local/lib/libxerces-c.dylib /opt/local/lib/libxml2.dylib /opt/local/lib/libxslt.dylib /opt/local/lib/libxerces-c.dylib

By adding all undefined symbols to the -Wl,-flat_namespace,-U,_convert_to_boolean,-U,... switch, it compiled fine.
The undefined symbols as reported are:
_zval_is_true
_zend_lookup_class
__object_init
__zend_hash_add_or_update
_php_strtolower

 So the command with -Wl,-flat_namespace,-U,_convert_to_boolean,-U,...,-U,_zval_is_true,-U,_zend_lookup_class,-U,__object_init,-U,__zend_hash_add_or_update,-U,_php_strtolower
compiled fine

The list of undefined symbols is in cmake_modules/FindPHP5.cmake, so the fix would be to update this file.

Also the output name of the zorba extension should be consistent with the content of zorba_api_wrapper.php:
- zorba_api_wrapper.php tries to load zorba_api.so
- the extension file is libzorba_api.so.

Once this is fixed, and php is configured to find the extension it works fine.

$ php simple.php
Example1:
<?xml version="1.0" encoding="UTF-8"?>
2

Example2:
2

Example3:
(no URI):1,1: dynamic error [err:FOAR0001]: division by zero

Example4:
(no URI):1,17: static error [err:XPST0003]: invalid expression: syntax error, unexpected "end of file"

Example5:
<?xml version="1.0" encoding="UTF-8"?>
<book>Book 1</book><book>Book 2</book>