Re: How to link extension with a static library?
| From: | Kārlis Repsons | Date: | Fri, 10 Feb 2012 12:50:01 +0000 |
| Subject: | Re: How to link extension with a static library? | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-9116@lists.php.net to get a copy of this message | ||
Laruence  Xinchen Hui wrote:
> you just only need to give a static library to it.
We had a small conversation about this, but it still didn't explain me
how to "give" a
static library to g++ linker. It has to be done through config.m4, but how?
Please consider the following example code and post about how to change it. Note
that building may not involve dependency on superuser privileges...
PHP_ARG_ENABLE( PCar_demo,
[Whether to enable PCar_demo extension],
[ --enable-pcar-demo Enable PCar_demo extension] \
)
if test "$PHP_PCAR_DEMO" != "no"
then
AC_DEFINE(HAVE_PCAR_DEMO, 1, [Whether you have PCar_demo])
PHP_REQUIRE_CXX()
PHP_ADD_INCLUDE(../)
...
PHP_ADD_LIBPATH(../path/to/where/my_static_lib/is/)
..
PHP_SUBST(PCAR_DEMO_SHARED_LIBADD)
???PHP_ADD_LIBRARY(my_static_lib)
PHP_ADD_LIBRARY(stdc++, 1, PCAR_DEMO_SHARED_LIBADD)
PHP_ADD_LIBRARY(boost_regex, 1, PCAR_DEMO_SHARED_LIBADD)
...
myext_sources=" \
php_main.cpp \
logger.cpp \
"
PHP_NEW_EXTENSION(PCar_demo, $myext_sources, $ext_shared,,
-Wno-write-strings, 1)
fi