Hi,
I am trying to build a stub of a C++ extension, with just some
empty classes, just so I can get the build and link process
down. I will add real code later.
My two main references for this are this HOWTO and the php
documentation:
http://bugs.tutorbuddy.com/phpcpp/phpcpp/index.html
http://www.php.net/manual/en/zend.creating.php
I have set up the source files account to the tutorbuddy
howto. (They are in an extension directory named cppext2 not
cppext, because I have tried several different things by now.)
When I get everything set up and build, it doesn't build the
class.cpp file, even though that is listed in the config.m4
file. I compared my config.m4 to the one in the cryptocpp
extension also on tutorbuddy (because that was the only other
C++ PHP extension I could find). It seems right. In
particular, the source files are listed in a line like this:
PHP_NEW_EXTENSION(cppext2, cppext2.cpp class.cpp, $ext_shared)
And yet when I configure all of PHP with --with-cppext2, and
build, I get this for the very first part of the build
process:
[EMAIL PROTECTED] php-4.3.4]# make
/bin/sh /root/php-extension/php-4.3.4/libtool --silent --preserve-dup-deps
--mode=compile g++ -Iext/cppext2/ -I/root/php-extension/php-4.3.4/ext/cppext2/
-DPHP_ATOM_INC -I/root/php-extension/php-4.3.4/include
-I/root/php-extension/php-4.3.4/main -I/root/php-extension/php-4.3.4
-I/root/php-extension/php-4.3.4/Zend -I/root/php-extension/php-4.3.4/ext/xml/expat
-I/root/php-extension/php-4.3.4/TSRM -g -O2 -prefer-pic -c
/root/php-extension/php-4.3.4/ext/cppext2/cppext2.cpp -o ext/cppext2/cppext2.lo
/bin/sh /root/php-extension/php-4.3.4/libtool --silent --preserve-dup-deps
--mode=compile gcc -Iext/ctype/ -I/root/php-extension/php-4.3.4/ext/ctype/
-DPHP_ATOM_INC -I/root/php-extension/php-4.3.4/include
-I/root/php-extension/php-4.3.4/main -I/root/php-extension/php-4.3.4
-I/root/php-extension/php-4.3.4/Zend -I/root/php-extension/php-4.3.4/ext/xml/expat
-I/root/php-extension/php-4.3.4/TSRM -march=athlon-xp -O2 -prefer-pic -c
/root/php-extension/php-4.3.4/ext/ctype/ctype.c -o ext/ctype/ctype.lo
As you can see, it only builds cppext2.cpp and then jumps
right to building the next extension. Then at the end,
because it didn't build the class.cpp, it complains about
undefined references and fails to link:
ext/cppext2/cppext2.lo(.text+0xe4): In function `zif_myphpclass(int, _zval_struct*,
_zval_struct*, int)':
/usr/include/c++/3.2.2/bits/stl_alloc.h:664: undefined reference to
`MyPHPClass::MyPHPClass[in-charge](std::basic_string<char, std::char_traits<char>,
std::allocator<char> >)'
ext/cppext2/cppext2.lo(.text+0x26e): In function `zif_myphpclass_getstring(int,
_zval_struct*, _zval_struct*, int)':
/usr/include/c++/3.2.2/bits/basic_string.h:781: undefined reference to
`MyPHPClass::getString() const'
ext/cppext2/cppext2.lo(.text+0x2ab):/usr/include/c++/3.2.2/bits/basic_string.h:391:
undefined reference to `MyPHPClass::getString() const'
ext/cppext2/cppext2.lo(.text+0x416): In function `zif_myphpclass_setstring(int,
_zval_struct*, _zval_struct*, int)':
/usr/include/c++/3.2.2/bits/stl_alloc.h:664: undefined reference to
`MyPHPClass::setString(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >)'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
[EMAIL PROTECTED] php-4.3.4]#
So how do I get it to build all the files ? Do I need to list
the files in another place besides config.m4 ? The cryptocpp
extension also lists them in a Makefile.in, but when I added
such a file on the same pattern listing my files, nothing
different happened in the build.
Do I need to run the phpize command ? I see references to it
in various documentation, but things seem to work as far as
they go without it, and running it puts a lot of stuff in the
extension directory without actually changing anything that
happens when I build.
I think my next step will be to install libcrypto++ on my
machine so I can enable the cryptocpp module, make sure that
works, and then try to copy that to a new extension directory
and gradually strip it down until I have a C++ extension
template. It shouldn't really be this hard, so I must be
missing something simple . . . please respond with any hints
or tips even if you don't know the complete answer to these
problems, I can use all the help I can get.
Thanks in advance !
--Rob
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php