Re: How to link extension with a static library?

From: Date: Sat, 11 Feb 2012 03:43:45 +0000
Subject: Re: How to link extension with a static library?
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-9120@lists.php.net to get a copy of this message
On Fri, Feb 10, 2012 at 8:50 PM, Kārlis Repsons <karlis.repsons@gmail.com> wrote: > 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? Hi: Iet me try to explain detailedly: gcc prefer a dynamic lib than static one. to accomplish your need, there are generally two ways IMO: 1. you can use -Wl, -Bstatic -lxxx to tell gcc link to a static xxx library. (you may want to google it) 2. since gcc is prefer a dynamic lib, so let's remove the dynamic librarys, only leave the static ones (this is what I described before). thanks > > 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 > -- Laruence  Xinchen Hui http://www.laruence.com/

« previous php.pecl.dev (#9120) next »