Re: How to link extension with a static library?
| From: | Anatoliy Belsky | Date: | Fri, 10 Feb 2012 17:58:37 +0000 |
| Subject: | Re: How to link extension with a static library? | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-9119@lists.php.net to get a copy of this message | ||
Hi Kārlis,
the following two lines are about how to compile with static libs
gcc -o myprog.o -I/my/headers -c myprog.c
gcc -o myprog myprog.o -L/my/libs -lmysuper
And there must exist /my/libs/libmysuper.a and mysuper lib headers if any.
The same works for g++
The piece of code looks ok therefore ok, not sure you take correct macros
for that.
Regards
Anatoliy
Am Fr, 10.02.2012, 13:50 schrieb Kārlis Repsons:
> 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
>
> --
> PECL development discussion Mailing List (http://pecl.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>