Note that there are some explanatory texts on larger screens.

plurals
  1. POIntegrating C++ class into PHP using SWIG
    primarykey
    data
    text
    <p>I'm using SWIG to integrate a C++ class into PHP, but for some reason the class does not appear correctly in PHP, even though a function does appear correctly. This is SWIG 2.0.4 and PHP 5.3.6 on Mac OS X 10.5.8. Here is the code and the commands used to build the library:</p> <pre><code>$ cat example.i %{ #include &lt;stdio.h&gt; #include "example.h" int Example::foo(void) { printf("This is foo\n"); return 0; } %} %module example class Example { public: int foo(void); }; $ cat example.h class Example { public: int foo(void); }; $ make ehphp /opt/local/bin/swig -c++ -php5 example.i g++ `php-config --includes` -fPIC -c example_wrap.cpp -o example_wrap.o g++ -dynamiclib -Wl,-flat_namespace,-U,_zend_register_resource,-U,_zend_rsrc_list_get_rsrc_type,-U,_zend_wrong_param_count,-U,_compiler_globals,-U,_zend_hash_find,-U,_gc_remove_zval_from_buffer,-U,_zend_register_long_constant,-U,_zend_get_constant,-U,__efree,-U,__emalloc,-U,_zend_error,-U,__zend_list_find,-U,_main,-U,__zend_get_parameters_array_ex,-U,_zend_register_list_destructors_ex,-U,__zval_copy_ctor_func,-U,__convert_to_string,-U,__zend_hash_add_or_update,-U,_executor_globals,-U,_zval_used_for_init,-U,_zval_is_true,-U,__object_init,-U,_php_strtolower,-U,__estrndup,-U,__object_init_ex,-U,_zend_lookup_class -o ehphp.dylib example_wrap.o sudo cp ehphp.dylib /opt/local/lib/php/extensions/no-debug-non-zts-20090626/ehphp.dylib $ php -a Interactive shell php &gt; var_dump(dl("ehphp.dylib")); bool(true) php &gt; var_dump(function_exists("bar")); bool(true) php &gt; var_dump(class_exists("Example")); bool(false) php &gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload