You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Devin Ceartas <de...@nacredata.com> on 2009/12/08 00:44:45 UTC

Linking in libraries to Apache Module

Playing around with this a bit, but not getting too far...

The logic of my SQLite code works if I compile it as a stand-alone  
executable.

My mod_hello.c compiles and loads/works fine without the SQLite code

Combining the two, the module compiles and is installed, but the  
apache process dies immediately (core dump) every time it is loaded.  
Stripping out all the SQLite code and simply linking against SQLite  
causes this problem. In other words, with the same code:

apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
/* Works Fine, prints "hello world" */

apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
/* compiles but dies on apache load */
The platform is OpenBSD 4.6 with the platform's version of Apache 1.3  
and SQLite 3.6.20 downloaded from the SQLite site and compiled from  
source

Since I'm just getting started with C apache modules, I assume I'm  
missing something basic. 

Re: Linking in libraries to Apache Module

Posted by Devin Ceartas <de...@nacredata.com>.
OK, got it. Understood. Good point, will do. :-) devin

On Dec 7, 2009, at 11:31 PM, Ray Morris wrote:

>> So, for what it's worth, it ends up that it will work with either
>> the direct linking as I was trying or with LoadFile
>
>   It will work FOR NOW, on that ONE SERVER, if you directly
> link a library.  Loadfile will work now, and in the future,
> and on other servers, rather than causing incorrect results
> or crashes in the future.
> --
> Ray Morris
> support@bettercgi.com
>
> Strongbox - The next generation in site security:
> http://www.bettercgi.com/strongbox/
>
> Throttlebox - Intelligent Bandwidth Control
> http://www.bettercgi.com/throttlebox/
>
> Strongbox / Throttlebox affiliate program:
> http://www.bettercgi.com/affiliates/user/register.php
>
>
> On 12/07/2009 09:59:41 PM, Devin Ceartas wrote:
>> So, for what it's worth, it ends up that it will work with either  
>> the direct linking as I was trying or with LoadFile
>> The problem had to do with my downloading SQLite and compiling -  
>> when I deleted all those resulting files and installed the OpenBSD  
>> package for SQLite, it worked fine. So there must be some platform- 
>> specific compile tweaks needed for that library.
>> -- devin
>> On Dec 7, 2009, at 9:24 PM, Nick Kew wrote:
>>> On 7 Dec 2009, at 23:44, Devin Ceartas wrote:
>>>> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
>>>> /* Works Fine, prints "hello world" */
>>>> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
>>>> /* compiles but dies on apache load */
>>>> The platform is OpenBSD 4.6 with the platform's version of Apache  
>>>> 1.3 and SQLite 3.6.20 downloaded from the SQLite site and  
>>>> compiled from source
>>> Don't link libsqlite.
>>> apr_dbd may already be loading libsqlite.  If for instance you've
>>> got more than one libsqlite installed and the two load different
>>> versions, segfault is the expected outcome.
>>> If apache DBD API doesn't meet your needs, you can invoke
>>> sqlite directly, but use LoadFile so sysops can load libsqlite if
>>> and only if it's not already loaded.
>>> --Nick Kew


Re: Linking in libraries to Apache Module

Posted by Ray Morris <su...@bettercgi.com>.
> So, for what it's worth, it ends up that it will work with either
> the direct linking as I was trying or with LoadFile

    It will work FOR NOW, on that ONE SERVER, if you directly
link a library.  Loadfile will work now, and in the future,
and on other servers, rather than causing incorrect results
or crashes in the future.
--
Ray Morris
support@bettercgi.com

Strongbox - The next generation in site security:
http://www.bettercgi.com/strongbox/

Throttlebox - Intelligent Bandwidth Control
http://www.bettercgi.com/throttlebox/

Strongbox / Throttlebox affiliate program:
http://www.bettercgi.com/affiliates/user/register.php


On 12/07/2009 09:59:41 PM, Devin Ceartas wrote:
> So, for what it's worth, it ends up that it will work with either the  
> direct linking as I was trying or with LoadFile
> 
> The problem had to do with my downloading SQLite and compiling - when  
> I deleted all those resulting files and installed the OpenBSD package  
> for SQLite, it worked fine. So there must be some platform-specific  
> compile tweaks needed for that library.
> 
> -- devin
> 
> 
> On Dec 7, 2009, at 9:24 PM, Nick Kew wrote:
> 
>> 
>> On 7 Dec 2009, at 23:44, Devin Ceartas wrote:
>> 
>>> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
>>> /* Works Fine, prints "hello world" */
>>> 
>>> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
>>> /* compiles but dies on apache load */
>>> The platform is OpenBSD 4.6 with the platform's version of Apache  
>>> 1.3 and SQLite 3.6.20 downloaded from the SQLite site and compiled  
>>> from source
>> 
>> Don't link libsqlite.
>> 
>> apr_dbd may already be loading libsqlite.  If for instance you've
>> got more than one libsqlite installed and the two load different
>> versions, segfault is the expected outcome.
>> 
>> If apache DBD API doesn't meet your needs, you can invoke
>> sqlite directly, but use LoadFile so sysops can load libsqlite if
>> and only if it's not already loaded.
>> 
>> --Nick Kew
> 

Re: Linking in libraries to Apache Module

Posted by Devin Ceartas <de...@nacredata.com>.
So, for what it's worth, it ends up that it will work with either the  
direct linking as I was trying or with LoadFile

The problem had to do with my downloading SQLite and compiling - when  
I deleted all those resulting files and installed the OpenBSD package  
for SQLite, it worked fine. So there must be some platform-specific  
compile tweaks needed for that library.

-- devin


On Dec 7, 2009, at 9:24 PM, Nick Kew wrote:

>
> On 7 Dec 2009, at 23:44, Devin Ceartas wrote:
>
>> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
>> /* Works Fine, prints "hello world" */
>>
>> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
>> /* compiles but dies on apache load */
>> The platform is OpenBSD 4.6 with the platform's version of Apache  
>> 1.3 and SQLite 3.6.20 downloaded from the SQLite site and compiled  
>> from source
>
> Don't link libsqlite.
>
> apr_dbd may already be loading libsqlite.  If for instance you've
> got more than one libsqlite installed and the two load different
> versions, segfault is the expected outcome.
>
> If apache DBD API doesn't meet your needs, you can invoke
> sqlite directly, but use LoadFile so sysops can load libsqlite if
> and only if it's not already loaded.
>
> -- 
> Nick Kew


Re: Linking in libraries to Apache Module

Posted by Devin Ceartas <de...@nacredata.com>.
OK, these ideas sound useful, thanks. I'll look into DBD and LoadFile.  
Thanks for your time.

On Dec 7, 2009, at 9:24 PM, Nick Kew <ni...@apache.org> wrote:

>
> On 7 Dec 2009, at 23:44, Devin Ceartas wrote:
>
>> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
>> /* Works Fine, prints "hello world" */
>>
>> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
>> /* compiles but dies on apache load */
>> The platform is OpenBSD 4.6 with the platform's version of Apache  
>> 1.3 and SQLite 3.6.20 downloaded from the SQLite site and compiled  
>> from source
>
> Don't link libsqlite.
>
> apr_dbd may already be loading libsqlite.  If for instance you've
> got more than one libsqlite installed and the two load different
> versions, segfault is the expected outcome.
>
> If apache DBD API doesn't meet your needs, you can invoke
> sqlite directly, but use LoadFile so sysops can load libsqlite if
> and only if it's not already loaded.
>
> -- 
> Nick Kew

Re: Linking in libraries to Apache Module

Posted by Nick Kew <ni...@apache.org>.
On 7 Dec 2009, at 23:44, Devin Ceartas wrote:

> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
> /* Works Fine, prints "hello world" */
> 
> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
> /* compiles but dies on apache load */
> The platform is OpenBSD 4.6 with the platform's version of Apache 1.3 and SQLite 3.6.20 downloaded from the SQLite site and compiled from source

Don't link libsqlite.

apr_dbd may already be loading libsqlite.  If for instance you've
got more than one libsqlite installed and the two load different
versions, segfault is the expected outcome.

If apache DBD API doesn't meet your needs, you can invoke
sqlite directly, but use LoadFile so sysops can load libsqlite if
and only if it's not already loaded.

-- 
Nick Kew

Re: Linking in libraries to Apache Module

Posted by Devin Ceartas <de...@nacredata.com>.
I don't know enough to understand the output yet, but to me it seems  
to indicate that the library is not missing:

# ldd /usr/lib/apache/modules/mod_hello2.so
/usr/lib/apache/modules/mod_hello2.so:
         Start    End      Type Open Ref GrpRef Name
         09384000 29388000 dlib 1    0   0      /usr/lib/apache/ 
modules/mod_hello2.so
         09fe8000 29ff5000 rlib 0    1   0      /usr/local/lib/ 
libsqlite3.so.8.6
         05d02000 25d0b000 rlib 0    1   0      /usr/lib/libpthread.so. 
11.1

Thanks!
-devin

On Dec 7, 2009, at 8:00 PM, Dennis J. wrote:

> Have you tried "ldd <path-to-compiled-module>"? That could also give  
> you a hint if anything is fishy with the library paths/dependencies.
>
> Regards,
>  Dennis
>
> On 12/08/2009 01:07 AM, Devin Ceartas wrote:
>> hm. -rpath doesn't seem to be an accepted flag in the apxs included  
>> with
>> the latest OpenBSD
>> -- devin
>>
>> On Dec 7, 2009, at 6:56 PM, Joe Lewis wrote:
>>
>>> Devin Ceartas wrote:
>>>> The logic of my SQLite code works if I compile it as a stand-alone
>>>> executable.
>>>>
>>>> My mod_hello.c compiles and loads/works fine without the SQLite  
>>>> code
>>>>
>>>> Combining the two, the module compiles and is installed, but the
>>>> apache process dies immediately (core dump) every time it is  
>>>> loaded.
>>>> Stripping out all the SQLite code and simply linking against SQLite
>>>> causes this problem. In other words, with the same code:
>>>>
>>>> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
>>>> /* Works Fine, prints "hello world" */
>>>>
>>>> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
>>>> /* compiles but dies on apache load */
>>>> The platform is OpenBSD 4.6 with the platform's version of Apache  
>>>> 1.3
>>>> and SQLite 3.6.20 downloaded from the SQLite site and compiled from
>>>> source
>>>>
>>>> Since I'm just getting started with C apache modules, I assume I'm
>>>> missing something basic.
>>>
>>> If using a Linux-based system, I'd suggest ensuring that  
>>> ld.so.conf is
>>> setup to point to the directory or that the compile has the runtime
>>> path for the sqlite library. For example, I have added "-rpath
>>> /usr/local/lib -rpath /usr/local/lib/mysql" to my -L parameters for
>>> apxs to load mySQL external modules dynamically in the past.
>>>
>>> Linux-based systems also have an "strace" command that may be used  
>>> to
>>> figure out what libraries are missing.
>>>
>>> --
>>> Joe Lewis
>>> Chief Nerd SILVERHAWK <http://www.silverhawk.net/> (801) 660-1900
>>>
>>> ------------------------------------------------------------------------
>>> /Rights that do not flow directly from duty well performed are not
>>> worth having.
>>> --Mohandas K. Gandhi/
>>
>


Re: Linking in libraries to Apache Module

Posted by "Dennis J." <de...@conversis.de>.
Have you tried "ldd <path-to-compiled-module>"? That could also give you a 
hint if anything is fishy with the library paths/dependencies.

Regards,
   Dennis

On 12/08/2009 01:07 AM, Devin Ceartas wrote:
> hm. -rpath doesn't seem to be an accepted flag in the apxs included with
> the latest OpenBSD
> -- devin
>
> On Dec 7, 2009, at 6:56 PM, Joe Lewis wrote:
>
>> Devin Ceartas wrote:
>>> The logic of my SQLite code works if I compile it as a stand-alone
>>> executable.
>>>
>>> My mod_hello.c compiles and loads/works fine without the SQLite code
>>>
>>> Combining the two, the module compiles and is installed, but the
>>> apache process dies immediately (core dump) every time it is loaded.
>>> Stripping out all the SQLite code and simply linking against SQLite
>>> causes this problem. In other words, with the same code:
>>>
>>> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
>>> /* Works Fine, prints "hello world" */
>>>
>>> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
>>> /* compiles but dies on apache load */
>>> The platform is OpenBSD 4.6 with the platform's version of Apache 1.3
>>> and SQLite 3.6.20 downloaded from the SQLite site and compiled from
>>> source
>>>
>>> Since I'm just getting started with C apache modules, I assume I'm
>>> missing something basic.
>>
>> If using a Linux-based system, I'd suggest ensuring that ld.so.conf is
>> setup to point to the directory or that the compile has the runtime
>> path for the sqlite library. For example, I have added "-rpath
>> /usr/local/lib -rpath /usr/local/lib/mysql" to my -L parameters for
>> apxs to load mySQL external modules dynamically in the past.
>>
>> Linux-based systems also have an "strace" command that may be used to
>> figure out what libraries are missing.
>>
>> --
>> Joe Lewis
>> Chief Nerd SILVERHAWK <http://www.silverhawk.net/> (801) 660-1900
>>
>> ------------------------------------------------------------------------
>> /Rights that do not flow directly from duty well performed are not
>> worth having.
>> --Mohandas K. Gandhi/
>


Re: Linking in libraries to Apache Module

Posted by Eric Covener <co...@gmail.com>.
On Mon, Dec 7, 2009 at 7:07 PM, Devin Ceartas <de...@nacredata.com> wrote:
> hm. -rpath doesn't seem to be an accepted flag in the apxs included with the
> latest OpenBSD

apxs will pass linker or compiler args down to the respective program
with -Wl, or -Wc, ; it doesn't do anything with them directly.

-- 
Eric Covener
covener@gmail.com

Re: Linking in libraries to Apache Module

Posted by Devin Ceartas <de...@nacredata.com>.
hm. -rpath doesn't seem to be an accepted flag in the apxs included  
with the latest OpenBSD
-- devin

On Dec 7, 2009, at 6:56 PM, Joe Lewis wrote:

> Devin Ceartas wrote:
>> The logic of my SQLite code works if I compile it as a stand-alone  
>> executable.
>>
>> My mod_hello.c compiles and loads/works fine without the SQLite code
>>
>> Combining the two, the module compiles and is installed, but the  
>> apache process dies immediately (core dump) every time it is  
>> loaded. Stripping out all the SQLite code and simply linking  
>> against SQLite causes this problem. In other words, with the same  
>> code:
>>
>> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
>> /* Works Fine, prints "hello world" */
>>
>> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
>> /* compiles but dies on apache load */
>> The platform is OpenBSD 4.6 with the platform's version of Apache  
>> 1.3 and SQLite 3.6.20 downloaded from the SQLite site and compiled  
>> from source
>>
>> Since I'm just getting started with C apache modules, I assume I'm  
>> missing something basic.
>
> If using a Linux-based system, I'd suggest ensuring that ld.so.conf  
> is setup to point to the directory or that the compile has the  
> runtime path for the sqlite library.  For example, I have added  "- 
> rpath /usr/local/lib -rpath /usr/local/lib/mysql" to my -L  
> parameters for apxs to load mySQL external modules dynamically in  
> the past.
>
> Linux-based systems also have an "strace" command that may be used  
> to figure out what libraries are missing.
>
> -- 
> Joe Lewis
> Chief Nerd 	SILVERHAWK <http://www.silverhawk.net/> 	(801) 660-1900
>
> ------------------------------------------------------------------------
> /Rights that do not flow directly from duty well performed are not  
> worth having.
>   --Mohandas K. Gandhi/


Re: Linking in libraries to Apache Module

Posted by Joe Lewis <jo...@joe-lewis.com>.
Devin Ceartas wrote:
> The logic of my SQLite code works if I compile it as a stand-alone 
> executable.
>
> My mod_hello.c compiles and loads/works fine without the SQLite code
>
> Combining the two, the module compiles and is installed, but the 
> apache process dies immediately (core dump) every time it is loaded. 
> Stripping out all the SQLite code and simply linking against SQLite 
> causes this problem. In other words, with the same code:
>
> apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
> /* Works Fine, prints "hello world" */
>
> apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
> /* compiles but dies on apache load */
> The platform is OpenBSD 4.6 with the platform's version of Apache 1.3 
> and SQLite 3.6.20 downloaded from the SQLite site and compiled from 
> source
>
> Since I'm just getting started with C apache modules, I assume I'm 
> missing something basic.

If using a Linux-based system, I'd suggest ensuring that ld.so.conf is 
setup to point to the directory or that the compile has the runtime path 
for the sqlite library.  For example, I have added  "-rpath 
/usr/local/lib -rpath /usr/local/lib/mysql" to my -L parameters for apxs 
to load mySQL external modules dynamically in the past.

Linux-based systems also have an "strace" command that may be used to 
figure out what libraries are missing.

-- 
Joe Lewis
Chief Nerd 	SILVERHAWK <http://www.silverhawk.net/> 	(801) 660-1900

------------------------------------------------------------------------
/Rights that do not flow directly from duty well performed are not worth 
having.
    --Mohandas K. Gandhi/