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 Mike <dy...@gmail.com> on 2007/06/28 08:22:19 UTC

Compilation problem on Mac OS

Hello.

When I'm trying to compile my example module on Mac OS I get following
error:

ld: Undefined
symbols:

_ap_filter_flush
_ap_hook_handler
_ap_pass_brigade
_ap_register_output_filter
_ap_rputs
_ap_set_content_type

Those functions as you know are core Apache members and they reside in httpd
binary.
What's wrong? What should I do to compile the module. (Module compiles
without any error on Linux machine).

Kind regards.

Re: Compilation problem on Mac OS

Posted by Mike <dy...@gmail.com>.
On Thu, Jun 28, 2007 at 03:11:05PM +0200, Giuliano Gavazzi wrote:
> and please do quote the text you reply to, since by not doing so you end up 
> producing text that does not make sense like the one above...
I apologize. I was writing from Google Web interface at that moment which is a little
bit confusing for me.
Kind regards.

Re: Compilation problem on Mac OS

Posted by Giuliano Gavazzi <de...@humph.com>.
On 28 Jun 2007, at 13:36, Mike wrote:

> Anyway, without seeing the actual commands you are using to do the
> compilation and then link the .so file, doing it properly with apxs is
> all I can suggest.
> Ok, I got your point. I'm gonna try to use apxs and post current  
> Makefile as
> soon as I reach home.
> Thanks for pointer.

and please do quote the text you reply to, since by not doing so you  
end up producing text that does not make sense like the one above...

Giuliano

Re: Debian 4 issue

Posted by Mike <dy...@gmail.com>.
On Sun, Jul 15, 2007 at 05:10:46PM +0200, Ralf Mattes wrote:
> You need to declare the following as "C":
He doesn't. It won't change anything.

Re: Debian 4 issue

Posted by Farokh Irani <fa...@mcfsoftware.com>.
>On Sun, 2007-07-15 at 10:44 -0400, Farokh Irani wrote:
>>  >No - you are not! You are using g++-4... which is a C++ compiler. Are
>>  >you aware of C++ name mangling? Did you declare your exported symbols
>>  >'extern C'?
>>
>>  Um, yes, already done.
>>
>>  extern "C" module AP_MODULE_DECLARE_DATA fancy_module;
>>
>>  It's the first line after the includes.
>>
>>  Near the end of the file:
>
>You need to declare the following as "C":
>
>extern "C" {
>>  module AP_MODULE_DECLARE_DATA fancy_module = {
>>	STANDARD20_MODULE_STUFF,
>>	create_dir_mconfig,    /* create per-dir config structures    */
>>	merge_dir_mconfig,     /* merge  per-dir config structures    */
>>	NULL,                  /* create per-server config structures */
>>	NULL,                  /* merge  per-server config structures */
>>	fancy_cmds,            /* table of config file commands       */
>>	fancy_register_hooks   /* register hooks                      */
>>  };
>}
>
>HTH RalfD

I tried that, and as far as I can tell, it makes no difference. nm 
still shows the same list of symbols.
-- 

Farokh
----------------------------------------------------------------------------
MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.

Re: Debian 4 issue

Posted by Ralf Mattes <rm...@seid-online.de>.
On Sun, 2007-07-15 at 10:44 -0400, Farokh Irani wrote:
> >No - you are not! You are using g++-4... which is a C++ compiler. Are
> >you aware of C++ name mangling? Did you declare your exported symbols
> >'extern C'?
> 
> Um, yes, already done.
> 
> extern "C" module AP_MODULE_DECLARE_DATA fancy_module;
> 
> It's the first line after the includes.
> 
> Near the end of the file:

You need to declare the following as "C":

extern "C" {
> module AP_MODULE_DECLARE_DATA fancy_module = {
> 	STANDARD20_MODULE_STUFF,
> 	create_dir_mconfig,    /* create per-dir config structures    */
> 	merge_dir_mconfig,     /* merge  per-dir config structures    */
> 	NULL,                  /* create per-server config structures */
> 	NULL,                  /* merge  per-server config structures */
> 	fancy_cmds,            /* table of config file commands       */
> 	fancy_register_hooks   /* register hooks                      */
> };
}

HTH RalfD


Re: Debian 4 issue

Posted by Farokh Irani <fa...@mcfsoftware.com>.
>No - you are not! You are using g++-4... which is a C++ compiler. Are
>you aware of C++ name mangling? Did you declare your exported symbols
>'extern C'?

Um, yes, already done.

extern "C" module AP_MODULE_DECLARE_DATA fancy_module;

It's the first line after the includes.

Near the end of the file:

module AP_MODULE_DECLARE_DATA fancy_module = {
	STANDARD20_MODULE_STUFF,
	create_dir_mconfig,    /* create per-dir config structures    */
	merge_dir_mconfig,     /* merge  per-dir config structures    */
	NULL,                  /* create per-server config structures */
	NULL,                  /* merge  per-server config structures */
	fancy_cmds,            /* table of config file commands       */
	fancy_register_hooks   /* register hooks                      */
};

-- 

Farokh
----------------------------------------------------------------------------
MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.

Re: Debian 4 issue

Posted by Ralf Mattes <rm...@seid-online.de>.
On Sun, 2007-07-15 at 09:51 -0400, Farokh Irani wrote:
> I've set up a Debian 4 machine and I'm trying to compile/install a 
> small test module. I'm using APXS2 as follows:
> 
> apxs2 -ic -S CC=g++ -n mod_fancy mod_fancy.cpp config.cpp
> 
> It compiles, and installs the mod_fancy.so file in /usr/lib/apache2/modules.
> 
> But, when I try to get apache to load it, I get an error when apache starts:
> apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: Syntax error
>    on line 1 of /etc/apache2/mods-enabled/mod_fancy.load: Can't locate API
>    module structure `fancy_module' in file
>    /usr/lib/apache2/modules/mod_fancy.so:
>    /usr/lib/apache2/modules/mod_fancy.so: undefined symbol: fancy_module
> 
> Using nm on the .so file, I get the following:
> 000015e8 A __bss_start
> 000003b0 t call_gmon_start
> 000015e8 b completed.5621
> 000014e8 d __CTOR_END__
> 000014e4 d __CTOR_LIST__
>           w __cxa_finalize@@GLIBC_2.1.3
> 00000480 t __do_global_ctors_aux
> 000003e0 t __do_global_dtors_aux
> 000015e0 d __dso_handle
> 000014f0 d __DTOR_END__
> 000014ec d __DTOR_LIST__
> 000014f8 a _DYNAMIC
> 000015e8 A _edata
> 000015ec A _end
> 000004c4 T _fini
> 00000440 t frame_dummy
> 000004e0 r __FRAME_END__
> 000015cc a _GLOBAL_OFFSET_TABLE_
>           w __gmon_start__
> 00000475 t __i686.get_pc_thunk.bx
> 00000360 T _init
> 000014f4 d __JCR_END__
> 000014f4 d __JCR_LIST__
>           w _Jv_RegisterClasses
> 000015e4 d p.5619
> 
> Anyone have any ideas why the symbol isn't being exported? I'm using 
> gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21).

No - you are not! You are using g++-4... which is a C++ compiler. Are
you aware of C++ name mangling? Did you declare your exported symbols
'extern C'?

 Cheers, Ralf Mattes

> Thanks.


Debian 4 issue

Posted by Farokh Irani <fa...@mcfsoftware.com>.
I've set up a Debian 4 machine and I'm trying to compile/install a 
small test module. I'm using APXS2 as follows:

apxs2 -ic -S CC=g++ -n mod_fancy mod_fancy.cpp config.cpp

It compiles, and installs the mod_fancy.so file in /usr/lib/apache2/modules.

But, when I try to get apache to load it, I get an error when apache starts:
apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: Syntax error
   on line 1 of /etc/apache2/mods-enabled/mod_fancy.load: Can't locate API
   module structure `fancy_module' in file
   /usr/lib/apache2/modules/mod_fancy.so:
   /usr/lib/apache2/modules/mod_fancy.so: undefined symbol: fancy_module

Using nm on the .so file, I get the following:
000015e8 A __bss_start
000003b0 t call_gmon_start
000015e8 b completed.5621
000014e8 d __CTOR_END__
000014e4 d __CTOR_LIST__
          w __cxa_finalize@@GLIBC_2.1.3
00000480 t __do_global_ctors_aux
000003e0 t __do_global_dtors_aux
000015e0 d __dso_handle
000014f0 d __DTOR_END__
000014ec d __DTOR_LIST__
000014f8 a _DYNAMIC
000015e8 A _edata
000015ec A _end
000004c4 T _fini
00000440 t frame_dummy
000004e0 r __FRAME_END__
000015cc a _GLOBAL_OFFSET_TABLE_
          w __gmon_start__
00000475 t __i686.get_pc_thunk.bx
00000360 T _init
000014f4 d __JCR_END__
000014f4 d __JCR_LIST__
          w _Jv_RegisterClasses
000015e4 d p.5619

Anyone have any ideas why the symbol isn't being exported? I'm using 
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21).

Thanks.
-- 

Farokh
----------------------------------------------------------------------------
MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.

Re: Possibly OT: g++ 4.0.1 on Mac OS X

Posted by Farokh Irani <fa...@mcfsoftware.com>.
>If you have lots of non Apache specific modules then compile them with
>g++ direct if you want, but then compile Apache specific stuff with:
>
>  apxs -S CC=g++ -c mod_foo.c file1.c file2.c object1.o object2.o

I tried this, but I get an error:
ar: no archive members specified
(and that is followed by a list of ar commands).

Thanks.
-- 

Farokh
----------------------------------------------------------------------------
MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.

Re: Possibly OT: g++ 4.0.1 on Mac OS X

Posted by Graham Dumpleton <gr...@gmail.com>.
On 07/07/07, Farokh Irani <fa...@mcfsoftware.com> wrote:
> >On 06/07/07, Farokh Irani <fa...@mcfsoftware.com> wrote:
> >>I'm trying to link together a couple of .o files into a .so file
> >>using g++. The problem is that even though I have a -o specified, no
> >>file is generated and no error comes up. Any pointers on how to
> >>figure out what might be going on, or even where I could look for
> >>more info, would be appreciated.
> >>
> >>This is with g++ 4.0.1 on Mac OS X 10.4.10.
> >
> >If you are trying to create an Apache module .so, why aren't you using apxs?
> >
> >You can specify that g++ should be used instead of gcc by saying:
> >
> >  apxs -S CC=g++ -c mod_example.c
> >
> >This is much better and more portable than trying to create the .so
> >yourself. This is more so the case on MacOS X as how you build a
> >dynamically loadable module is different to options you would use for
> >other platforms. Also, on MacOS X a dynamically loadable module has to
> >be created in a different way to a shared library, they are not
> >interchangeable.
>
> OK, I'm willing to give that a shot, but how do I use apxs to
> compile/link a multi-file source module? IE Right now I've got a
> small module that has 3 files, but I expect the source tree to grow
> to many more (possibly a hundred or more source files).

Look at the manual page for 'apxs' on your system.

If you have lots of non Apache specific modules then compile them with
g++ direct if you want, but then compile Apache specific stuff with:

  apxs -S CC=g++ -c mod_foo.c file1.c file2.c object1.o object2.o

The apxs command can be given code files or existing compiled object
files (I think).

You could also put your non Apache specific files in a library and
link to that library when building the module.

  apxs -S CC=g++ -c mod_foo.c file1.c file2.c -lmylibrary

The important bit is using apxs for the compilation of Apache code
files and doing the final link to get the Apache module .so.

Graham

Re: Possibly OT: g++ 4.0.1 on Mac OS X

Posted by Farokh Irani <fa...@mcfsoftware.com>.
>On 06/07/07, Farokh Irani <fa...@mcfsoftware.com> wrote:
>>I'm trying to link together a couple of .o files into a .so file
>>using g++. The problem is that even though I have a -o specified, no
>>file is generated and no error comes up. Any pointers on how to
>>figure out what might be going on, or even where I could look for
>>more info, would be appreciated.
>>
>>This is with g++ 4.0.1 on Mac OS X 10.4.10.
>
>If you are trying to create an Apache module .so, why aren't you using apxs?
>
>You can specify that g++ should be used instead of gcc by saying:
>
>  apxs -S CC=g++ -c mod_example.c
>
>This is much better and more portable than trying to create the .so
>yourself. This is more so the case on MacOS X as how you build a
>dynamically loadable module is different to options you would use for
>other platforms. Also, on MacOS X a dynamically loadable module has to
>be created in a different way to a shared library, they are not
>interchangeable.

OK, I'm willing to give that a shot, but how do I use apxs to 
compile/link a multi-file source module? IE Right now I've got a 
small module that has 3 files, but I expect the source tree to grow 
to many more (possibly a hundred or more source files).
-- 

Farokh
----------------------------------------------------------------------------
MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.

Re: Possibly OT: g++ 4.0.1 on Mac OS X

Posted by Graham Dumpleton <gr...@gmail.com>.
On 06/07/07, Farokh Irani <fa...@mcfsoftware.com> wrote:
> I'm trying to link together a couple of .o files into a .so file
> using g++. The problem is that even though I have a -o specified, no
> file is generated and no error comes up. Any pointers on how to
> figure out what might be going on, or even where I could look for
> more info, would be appreciated.
>
> This is with g++ 4.0.1 on Mac OS X 10.4.10.

If you are trying to create an Apache module .so, why aren't you using apxs?

You can specify that g++ should be used instead of gcc by saying:

  apxs -S CC=g++ -c mod_example.c

This is much better and more portable than trying to create the .so
yourself. This is more so the case on MacOS X as how you build a
dynamically loadable module is different to options you would use for
other platforms. Also, on MacOS X a dynamically loadable module has to
be created in a different way to a shared library, they are not
interchangeable.

Graham

Possibly OT: g++ 4.0.1 on Mac OS X

Posted by Farokh Irani <fa...@mcfsoftware.com>.
I'm trying to link together a couple of .o files into a .so file 
using g++. The problem is that even though I have a -o specified, no 
file is generated and no error comes up. Any pointers on how to 
figure out what might be going on, or even where I could look for 
more info, would be appreciated.

This is with g++ 4.0.1 on Mac OS X 10.4.10.

Thanks.
-- 

Farokh
----------------------------------------------------------------------------
MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.

Re: Compilation problem on Mac OS

Posted by Mike <dy...@gmail.com>.
On 6/28/07, Graham Dumpleton <gr...@gmail.com> wrote:
> I don't think it's matter of use the apxs.
The point of using apxs, is that as long as you use the version of
apxs from the version of Apache you want to use, it will ensure that
the correct include files and libraries are always used. If you use
apxs to install the module it will also ensure that the module is
installed to the correct location.

By using your own compilation rules there will always be the
possibility that you miss something and pick up header files and/or
libraries from the wrong Apache version or that you don't use certain
platform specific compiler/linker options that may be required. Thus
using apxs would generally be a more reliable way of ensuring that
things are going to work correctly.

This is more so the case on MacOS X which requires a variety of
strange options when building the actual module .so itself. This is
because on MacOS X there is a difference between shared libraries and
dynamically loadable modules. Such a distinction does not exist on
Solaris and Linux platforms where a shared library is also usable as a
dynamically loadable module.

Anyway, without seeing the actual commands you are using to do the
compilation and then link the .so file, doing it properly with apxs is
all I can suggest.
Ok, I got your point. I'm gonna try to use apxs and post current Makefile as
soon as I reach home.
Thanks for pointer.

Re: Compilation problem on Mac OS

Posted by Graham Dumpleton <gr...@gmail.com>.
On 28/06/07, Mike <dy...@gmail.com> wrote:
> I don't think it's matter of use the apxs.

The point of using apxs, is that as long as you use the version of
apxs from the version of Apache you want to use, it will ensure that
the correct include files and libraries are always used. If you use
apxs to install the module it will also ensure that the module is
installed to the correct location.

By using your own compilation rules there will always be the
possibility that you miss something and pick up header files and/or
libraries from the wrong Apache version or that you don't use certain
platform specific compiler/linker options that may be required. Thus
using apxs would generally be a more reliable way of ensuring that
things are going to work correctly.

This is more so the case on MacOS X which requires a variety of
strange options when building the actual module .so itself. This is
because on MacOS X there is a difference between shared libraries and
dynamically loadable modules. Such a distinction does not exist on
Solaris and Linux platforms where a shared library is also usable as a
dynamically loadable module.

Anyway, without seeing the actual commands you are using to do the
compilation and then link the .so file, doing it properly with apxs is
all I can suggest.

Graham

Re: Compilation problem on Mac OS

Posted by Mike <dy...@gmail.com>.
On 6/28/07, Graham Dumpleton <gr...@gmail.com> wrote:
> > > Hello.
> > >
> > > When I'm trying to compile my example module on Mac OS I get following
> > > error:
> > >
> > > ld: Undefined
> > > symbols:
> > >
> > > _ap_filter_flush
> > > _ap_hook_handler
> > > _ap_pass_brigade
> > > _ap_register_output_filter
> > > _ap_rputs
> > > _ap_set_content_type
> > >
> > > Those functions as you know are core Apache members and they reside in
> > httpd
> > > binary.
> > > What's wrong? What should I do to compile the module. (Module compiles
> > > without any error on Linux machine).
> > How are you compiling the module, using 'apxs' or hand crafted
> > makefile rules that invoke the compiler directly?
>
>
> I need to use self-made Makefile since I'm writing module in C++.

Have you ever tried seeing how far you can get with apxs using the -S
option to set CC to be g++. Ie.,

  apxs -S CC=g++ -c mod_example.c

This presumes it is gcc that apxs was configured for.

You may find you have to override over values in apxs configuration as
well though if it passes through gcc options that g++ doesn't
understand.
I don't think it's matter of use the apxs.

Re: Compilation problem on Mac OS

Posted by Graham Dumpleton <gr...@gmail.com>.
On 28/06/07, Mike <dy...@gmail.com> wrote:
> On 6/28/07, Graham Dumpleton <gr...@gmail.com> wrote:
> >
> > On 28/06/07, Mike <dy...@gmail.com> wrote:
> > > Hello.
> > >
> > > When I'm trying to compile my example module on Mac OS I get following
> > > error:
> > >
> > > ld: Undefined
> > > symbols:
> > >
> > > _ap_filter_flush
> > > _ap_hook_handler
> > > _ap_pass_brigade
> > > _ap_register_output_filter
> > > _ap_rputs
> > > _ap_set_content_type
> > >
> > > Those functions as you know are core Apache members and they reside in
> > httpd
> > > binary.
> > > What's wrong? What should I do to compile the module. (Module compiles
> > > without any error on Linux machine).
> > How are you compiling the module, using 'apxs' or hand crafted
> > makefile rules that invoke the compiler directly?
>
>
> I need to use self-made Makefile since I'm writing module in C++.

Have you ever tried seeing how far you can get with apxs using the -S
option to set CC to be g++. Ie.,

  apxs -S CC=g++ -c mod_example.c

This presumes it is gcc that apxs was configured for.

You may find you have to override over values in apxs configuration as
well though if it passes through gcc options that g++ doesn't
understand.

Graham

Re: Compilation problem on Mac OS

Posted by Mike <dy...@gmail.com>.
On 6/28/07, Graham Dumpleton <gr...@gmail.com> wrote:
>
> On 28/06/07, Mike <dy...@gmail.com> wrote:
> > Hello.
> >
> > When I'm trying to compile my example module on Mac OS I get following
> > error:
> >
> > ld: Undefined
> > symbols:
> >
> > _ap_filter_flush
> > _ap_hook_handler
> > _ap_pass_brigade
> > _ap_register_output_filter
> > _ap_rputs
> > _ap_set_content_type
> >
> > Those functions as you know are core Apache members and they reside in
> httpd
> > binary.
> > What's wrong? What should I do to compile the module. (Module compiles
> > without any error on Linux machine).
> How are you compiling the module, using 'apxs' or hand crafted
> makefile rules that invoke the compiler directly?


I need to use self-made Makefile since I'm writing module in C++.


Which Apache installation are you using? Default Apache 1.3 that comes
> with the operating system? Other binary Apache distribution for MacOS
> X or compiled from source code?


Compiled from the source code. ver. 2.2

Since ap_set_content_type() isn't in Apache 1.3, but is in Apache 2.X,
> almost looks like you are using the Apache 1.3 that comes with the
> operating system.
> I'm gonna try to clean up the instalation and try one more time.
>

Re: Compilation problem on Mac OS

Posted by Graham Dumpleton <gr...@gmail.com>.
On 28/06/07, Mike <dy...@gmail.com> wrote:
> Hello.
>
> When I'm trying to compile my example module on Mac OS I get following
> error:
>
> ld: Undefined
> symbols:
>
> _ap_filter_flush
> _ap_hook_handler
> _ap_pass_brigade
> _ap_register_output_filter
> _ap_rputs
> _ap_set_content_type
>
> Those functions as you know are core Apache members and they reside in httpd
> binary.
> What's wrong? What should I do to compile the module. (Module compiles
> without any error on Linux machine).

How are you compiling the module, using 'apxs' or hand crafted
makefile rules that invoke the compiler directly?

Which Apache installation are you using? Default Apache 1.3 that comes
with the operating system? Other binary Apache distribution for MacOS
X or compiled from source code?

Since ap_set_content_type() isn't in Apache 1.3, but is in Apache 2.X,
almost looks like you are using the Apache 1.3 that comes with the
operating system.

Graham