Re: How to link extension with a static library?

From: Date: Mon, 13 Feb 2012 10:20:07 +0000
Subject: Re: How to link extension with a static library?
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-9123@lists.php.net to get a copy of this message
On Sat, Feb 11, 2012 at 4:43 AM, Laruence <laruence@php.net> wrote: > 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). > > Thx for reminder Laruence , but is there a way of specifying this inside the .m4 file ? Actually, one who wants to statically link should edit the Makefile by hand, not very handy ... Would be cool if a m4 MACRO() could do that. I have no clue about that :P Byeah Julien.P > 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/ > > -- > PECL development discussion Mailing List (http://pecl.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

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