Linking C++ extensions
| From: | Jon Parise | Date: | Mon, 31 Dec 2007 04:26:05 +0000 |
| Subject: | Linking C++ extensions | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-5009@lists.php.net to get a copy of this message | ||
I was working on a C++-based extension and kept running into this
module load failure:
Undefined symbol "_Znwj" in Unknown on line 0
A little research told me that this occurs (on FreeBSD, at least) when
a C++ extension is linked using gcc instead of g++. The extension's
generated Makefile contained this line:
libtool --mode=link gcc
Changing it to use g++ fixed the problem.
I couldn't find any prior information on this problem specific to PHP
extensions, but reading through the acinclude.m4 code taught me about
some additional parameters to PHP_NEW_EXTENSION(). Specifically, the
sixth (optional) parameter can be used to force C++ linkage, e.g.:
PHP_NEW_EXTENSION(ext, ext.cpp, $ext_shared,,, yes)
Everything looks good after I made this change. I don't see any of
the other PECL extensions using this additional parameter, however, so
I wanted to mention it here so that others would also be aware of it.
--
Jon Parise (jon of php.net) :: The PHP Project (http://www.php.net/)