SWIG PHP build failure on Mac OSX

Bug #867133 reported by Gabriel Petrovay
4
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
High
Matthias Brantner

Bug Description

See the zorba coders topic under: "Still SWIG problems..."

Linking CXX shared module libzorba_api.so
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
make[1]: *** [swig/php/CMakeFiles/zorba_api.dir/all] Error 2
make: *** [all] Error 2

Related branches

Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) wrote :

Please, elaborate, I can't reproduce this error...

Revision history for this message
Gabriel Petrovay (gabipetrovay) wrote :

This (still) is a problem on Mac OSX 10.6

Linking CXX shared module libzorba_api.so
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
make[1]: *** [swig/php/CMakeFiles/zorba_api.dir/all] Error 2
make: *** [all] Error 2

Revision history for this message
Gabriel Petrovay (gabipetrovay) wrote :

If this helps, CMake output relevant tot PHP is:

-- /usr/include/php/main
-- Found PHP5-Version 5.3.3

...

-- PHP Found and Active!
-- PHP Path:/Users/sausalito/builds/zorba/build/swig/php
-- PHP Extension Path: /Users/sausalito/builds/zorba/build/swig/php
-- Configuration file: /Users/sausalito/builds/zorba/build/doc/php/examples/php.ini
-- Simple configuration file: /Users/sausalito/builds/zorba/build/doc/php/examples/simple.php
-- Installing: /Users/sausalito/builds/zorba/build/doc/php/examples/simple.php

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

It seems like this guy had the same problem. There might be a hint how to solve it:

http://blog.liuzehua.com/post/5135443847/compiling-icephp-on-mac-os-x

Revision history for this message
akaplan (akaplan) wrote :
Download full text (3.6 KiB)

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 libzorb...

Read more...

Revision history for this message
William Candillon (wcandillon) wrote :

Hello,

Indeed this fix the bug.
Please find the patch enclosed.

Changed in zorba:
milestone: none → 2.1
Changed in zorba:
status: New → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.