logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: unable to complie a sample code for a module
Author
samapache



Joined: 18 Nov 2010
Posts: 7

PostPosted: Tue 23 Nov '10 10:13    Post subject: unable to complie a sample code for a module Reply with quote

Hi,
I downloaded a code from:

http://stein.cshl.org/~lstein/talks/perl_conference/apache_api/hello_world.html

which I am trying to compile on my Windows xp machine. I have installed following on my system:
1. Apache server
2. Cygwin
3. Perl

but when i use make command i get a error: make not found.
So i tried just: apxs -c mod_hello.c command at the command prompt: i got error:
==============================================
C:\Program Files\Apache Group\Apache2\bin\hello>apxs -c mod_hello.c
Use of assignment to $[ is deprecated at C:\Program Files\Apache Group\Apache2\b
in/apxs.bat line 120.
D:/Perl/site/bin/gcc.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG
-I"C:\PROGRA~1\APACHE~1\Apache2\include" /c /Fomod_hello.lo mod_hello.c
gcc.exe: /nologo: No such file or directory
gcc.exe: /MD: No such file or directory
gcc.exe: /W3: No such file or directory
gcc.exe: /O2: No such file or directory
gcc.exe: /D: No such file or directory
gcc.exe: WIN32: No such file or directory
gcc.exe: /D: No such file or directory
gcc.exe: _WINDOWS: No such file or directory
gcc.exe: /D: No such file or directory
gcc.exe: NDEBUG: No such file or directory
gcc.exe: /c: No such file or directory
gcc.exe: /Fomod_hello.lo: No such file or directory
mod_hello.c: In function `hello_handler':
mod_hello.c:19: error: too few arguments to function `ap_get_remote_host'
mod_hello.c:20: warning: assignment makes pointer from integer without a cast
mod_hello.c: At top level:
mod_hello.c:43: error: syntax error before "hello_handlers"
mod_hello.c:44: warning: braces around scalar initializer
mod_hello.c:44: warning: (near initialization for `hello_handlers[0]')
mod_hello.c:44: warning: initialization makes integer from pointer without a cas
t
mod_hello.c:44: warning: excess elements in scalar initializer
mod_hello.c:44: warning: (near initialization for `hello_handlers[0]')
mod_hello.c:45: warning: braces around scalar initializer
mod_hello.c:45: warning: (near initialization for `hello_handlers[1]')
mod_hello.c:45: warning: initialization makes integer from pointer without a cas
t
mod_hello.c:45: warning: excess elements in scalar initializer
mod_hello.c:45: warning: (near initialization for `hello_handlers[1]')
mod_hello.c:46: warning: data definition has no type or storage class
mod_hello.c:49: error: syntax error before "hello_module"
mod_hello.c:50: error: `this_module_needs_to_be_ported_to_apache_2_0' undeclared
here (not in a function)
mod_hello.c:50: error: initializer element is not constant
mod_hello.c:50: error: (near initialization for `hello_module')
mod_hello.c:51: warning: excess elements in scalar initializer
mod_hello.c:51: warning: (near initialization for `hello_module')
mod_hello.c:52: warning: excess elements in scalar initializer
mod_hello.c:52: warning: (near initialization for `hello_module')
mod_hello.c:53: warning: excess elements in scalar initializer
mod_hello.c:53: warning: (near initialization for `hello_module')
mod_hello.c:54: warning: excess elements in scalar initializer
mod_hello.c:54: warning: (near initialization for `hello_module')
mod_hello.c:55: warning: excess elements in scalar initializer
mod_hello.c:55: warning: (near initialization for `hello_module')
mod_hello.c:56: warning: excess elements in scalar initializer
mod_hello.c:56: warning: (near initialization for `hello_module')
mod_hello.c:57: warning: excess elements in scalar initializer
mod_hello.c:57: warning: (near initialization for `hello_module')
mod_hello.c:58: warning: excess elements in scalar initializer
mod_hello.c:58: warning: (near initialization for `hello_module')
mod_hello.c:59: warning: excess elements in scalar initializer
mod_hello.c:59: warning: (near initialization for `hello_module')
mod_hello.c:60: warning: excess elements in scalar initializer
mod_hello.c:60: warning: (near initialization for `hello_module')
mod_hello.c:61: warning: excess elements in scalar initializer
mod_hello.c:61: warning: (near initialization for `hello_module')
mod_hello.c:62: warning: excess elements in scalar initializer
mod_hello.c:62: warning: (near initialization for `hello_module')
mod_hello.c:63: warning: excess elements in scalar initializer
mod_hello.c:63: warning: (near initialization for `hello_module')
mod_hello.c:64: warning: excess elements in scalar initializer
mod_hello.c:64: warning: (near initialization for `hello_module')
mod_hello.c:65: warning: excess elements in scalar initializer
mod_hello.c:65: warning: (near initialization for `hello_module')
mod_hello.c:66: warning: excess elements in scalar initializer
mod_hello.c:66: warning: (near initialization for `hello_module')
mod_hello.c:67: warning: excess elements in scalar initializer
mod_hello.c:67: warning: (near initialization for `hello_module')
mod_hello.c:69: warning: excess elements in scalar initializer
mod_hello.c:69: warning: (near initialization for `hello_module')
mod_hello.c:69: warning: data definition has no type or storage class
apxs:Error: Command failed with rc=65536
===============================================

Can anyone tell me what I am missing. If I am missing MAKE command then i didnt find it on my system. I read somewhere that cygwin is required for running make but installing cygwin didnt help me though.

thanks
sam
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 23 Nov '10 13:32    Post subject: Reply with quote

That module has been written against Apache 1.3 and won't work to compile it against Apache 2.0 nor 2.2
OTOH the paramters for the compiler are for VC++ and not gcc.

the tutorial is from 1999, but better download httpd-2.2.17-win32-src.zip and take a look on mod_example

using VC++ on the command line is easy. (that are single lines without a linebreak you might see)

del *.obj *.exp *.lib *.so

set APACHE="C:\Program Files\Apache Group\Apache2"

cl /nologo /MD /O2 /LD /W3 -DWIN32 -D_WIN32 -I%APACHE%\include /c /Fomod_eaxmple.obj mod_eaxmple.c

link /NODEFAULTLIB:LIBCMT kernel32.lib "%APACHE%\lib\libhttpd.lib" "%APACHE%\lib\libapr-1.lib" "%APACHE%\lib\libaprutil-1.lib" /nologo /subsystem:windows /dll /out:mod_example.so mod_example.obj

MT -manifest mod_example.so.manifest -outputresource:mod_example.so;2



You compile many third party modules this way.
Back to top
samapache



Joined: 18 Nov 2010
Posts: 7

PostPosted: Tue 23 Nov '10 21:59    Post subject: Reply with quote

Thanks James. I was able to compile now on my windows system but it didnt generate mod_example.so but only mod_example.obj
==============================================
D:\Dumps\Apache\httpd-2.2.17\modules\experimental>cl /nologo /MD /O2 /LD /W3 -DWIN32 -D_WIN32 -I%APACHE%\include /c /Fo
ws /dll /out:mod_example.so mod_example.obj MT -manifest mod_example.so.manifest -outputresource:mod_example.so;
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9002 : ignoring unknown option '/NODEFAULTLIB:LIBCMT'
cl : Command line warning D9002 : ignoring unknown option '/subsystem:windows'
cl : Command line warning D9002 : ignoring unknown option '/dll'
cl : Command line warning D9002 : ignoring unknown option '-manifest'
cl : Command line warning D9024 : unrecognized source file type 'link', object file assumed
cl : Command line warning D9027 : source file 'link' ignored
cl : Command line warning D9027 : source file 'kernel32.lib' ignored
cl : Command line warning D9024 : unrecognized source file type 'C:\Program', object file assumed
cl : Command line warning D9027 : source file 'C:\Program' ignored
cl : Command line warning D9024 : unrecognized source file type 'Files\Apache', object file assumed
cl : Command line warning D9027 : source file 'Files\Apache' ignored
cl : Command line warning D9027 : source file 'Group\Apache2\lib\libhttpd.lib' ignored
cl : Command line warning D9024 : unrecognized source file type 'C:\Program', object file assumed
cl : Command line warning D9027 : source file 'C:\Program' ignored
cl : Command line warning D9024 : unrecognized source file type 'Files\Apache', object file assumed
cl : Command line warning D9027 : source file 'Files\Apache' ignored
cl : Command line warning D9027 : source file 'Group\Apache2\lib\libapr-1.lib' ignored
cl : Command line warning D9024 : unrecognized source file type 'C:\Program', object file assumed
cl : Command line warning D9027 : source file 'C:\Program' ignored
cl : Command line warning D9024 : unrecognized source file type 'Files\Apache', object file assumed
cl : Command line warning D9027 : source file 'Files\Apache' ignored
cl : Command line warning D9027 : source file 'Group\Apache2\lib\libaprutil-1.lib' ignored
cl : Command line warning D9027 : source file 'mod_example.obj' ignored
cl : Command line warning D9024 : unrecognized source file type 'MT', object file assumed
cl : Command line warning D9027 : source file 'MT' ignored
cl : Command line warning D9024 : unrecognized source file type 'mod_example.so.manifest', object file assumed
cl : Command line warning D9027 : source file 'mod_example.so.manifest' ignored
mod_example.c
mod_example.c(549) : warning C4013: 'ap_get_server_banner' undefined; assuming extern returning int
==========================================

thanks for your help
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Wed 24 Nov '10 12:40    Post subject: Reply with quote

it seems you ran all commands in a single line? Hm might be an issue do posting the stuff and line breaks.

it is ok that there is only the object file after running cl. The linker will create the .so file (.dll).


Last edited by James Blond on Tue 20 Mar '18 17:18; edited 1 time in total
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Wed 24 Nov '10 17:32    Post subject: Reply with quote

I hope that's not an Apache.org (vc6) version sitting in
C:\Program Files\Apache Group\Apache2.2

He looks to be using vc10.
Back to top
samapache



Joined: 18 Nov 2010
Posts: 7

PostPosted: Thu 25 Nov '10 3:08    Post subject: Reply with quote

Yes I ran the CL and LINK command together.
Obj file is getting created but Link command is giving me error.

I changed the LINK command as I was unable to find the libraries(libaprutil-1.lib and libapr-1.lib on my system so I changed the

link /NODEFAULTLIB:LIBCMT kernel32.lib "C:\Program Files\Apache Group\Apache2\lib\libhttpd.lib" "C:\Program Files\Apache Group\Apache2\lib\libapr.lib" "C:\Program Files\Apache Group\Apache2\lib\libaprutil.lib" /nologo /subsystem:windows /dll /out:mod_example.so mod_example.obj

I got error : LINK : fatal error LNK1104: cannot open file 'MSVCRT.lib'

I searched the file and its present @ D:\Program Files\Microsoft Visual Studio 9.0\VC\lib.
I added this in the PATH. But same error.

I also tried compiling the code in the VC2008 thats installed on my ssytem by the using the existing project file mod_example.dsp in the httpd package but got link error:

1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_log_error referenced in function _trace_add
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_table_set@12 referenced in function _trace_add
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_pstrcat referenced in function _trace_add
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_pool_destroy@4 referenced in function _trace_add
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_pstrdup@8 referenced in function _trace_add
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_pool_create_ex@16 referenced in function _trace_add
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_table_get@8 referenced in function _trace_add
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_table_make@8 referenced in function _setup_module_cells
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_palloc@8 referenced in function _x_create_dir_config
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_insert_filter@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_auth_checker@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_access_checker@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_type_checker@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_fixups@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_check_user_id@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_header_parser@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_map_to_storage@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_translate_name@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_log_transaction@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_post_read_request@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_process_connection@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_pre_connection@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_quick_handler@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_handler@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_child_init@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_open_logs@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_post_config@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_hook_pre_config@16 referenced in function _x_register_hooks
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_get_server_built@0 referenced in function _x_handler
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_rprintf referenced in function _x_handler
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_get_server_banner@0 referenced in function _x_handler
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_rputs@8 referenced in function _x_handler
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__ap_set_content_type@8 referenced in function _x_handler
1>mod_example.obj : error LNK2019: unresolved external symbol __imp__apr_pool_cleanup_register@16 referenced in function _x_child_init

Please note that I added the paths required for compilation.

Basically I want write C++ modules for Apache. Please also let me know if some document is available for it. But yes firstly the above issue is blocking for me.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Thu 25 Nov '10 7:40    Post subject: Reply with quote

OK, to me it looks like you are trying to build mod_example from 2.2.17 against Apache 2.0.x, this is not going to work because Apache 2.0 has a different structure than Apache 2.2 and that 2.0 was built on VC6, not VC9 (2008) or VC10 (2010)

I'd suggest downloading the 2.2.17 from here, and put somewhere on your hard drive, say c:\Apache22

What you will see is these apr*-1.lib files & libhttpd.lib in c:\Apache22\lib

I modified James' command a little as well as fixed a spelling error in the cl line.
http://www.apachehaus.net/mebuild.txt

Now in VC2008,
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\build9\httpd-2.2.17>cd modules\experimental

C:\build9\httpd-2.2.17\modules\experimental>set APACHE=C:\Apache22

C:\build9\httpd-2.2.17\modules\experimental>cl /nologo /MD /O2 /W3 -DWIN32 -D_WIN32 -I %APACHE%\incl
ude /c /Fomod_example.obj mod_example.c
mod_example.c

C:\build9\httpd-2.2.17\modules\experimental>link /NODEFAULTLIB:LIBCMT kernel32.lib "%APACHE%\lib\lib
httpd.lib" "%APACHE%\lib\libapr-1.lib" "%APACHE%\lib\libaprutil-1.lib" /nologo /subsystem:windows /d
ll /out:mod_example.so mod_example.obj
Creating library mod_example.lib and object mod_example.exp

C:\build9\httpd-2.2.17\modules\experimental>MT -manifest mod_example.so.manifest -outputresource:mod
_example.so;2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\build9\httpd-2.2.17\modules\experimental>

done, the module generated just now;
http://www.apachehaus.net/mod_example.zip
Back to top
samapache



Joined: 18 Nov 2010
Posts: 7

PostPosted: Fri 26 Nov '10 10:24    Post subject: Compiled... but not running Reply with quote

At last compiled but i need to change the LINK command to add: oldnames.lib and msvcrt.lb path explicitly.

link /NODEFAULTLIB:LIBCMT kernel32.lib "%APACHE%\lib\libhttpd.lib" "%APACHE%\lib\libapr-1.lib" "%APACHE%\lib\libaprutil-1.lib" "D:\Program Files\Microsoft Visual Studio 9.0\VC\lib\msvcrt.lib" "D:\Program Files\Microsoft Visual Studio 9.0\VC\lib\oldnames.lib" /nologo /subsystem:windows /dll /out:mod_example.so mod_example.obj

although this: D:\Program Files\Microsoft Visual Studio 9.0\VC\lib\ path is in PATH and LIBPATH env variables.

mod_example.so was created successfully. I copied it manually to the C:\Apache2.2\modules and then edited the httpd.conf and added a line:

LoadModule example_module modules/mod_example.so

and also added:

<Location /example-info>
SetHandler example-handler
</Location>

at the bottom of this file. Restatred the server and wrote:
http://localhost/example_info in the browser but got Page not found

My apache is working fine as http://localhost/ shows me "It Works" on the page.

Please let me know what error i made. Can you also please let me know how to write modules in C++.


Thanks
sam
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Fri 26 Nov '10 20:56    Post subject: Reply with quote

Hi sam,

I am not quite sure why it is not working, check your error log for any hint. If it 404s, there is something in there about it.

LIBPATH, I found I also have an ENV for just LIB
LIB = C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB;C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib;

You may want to add it to your system. It should be there when you open a VC++ 2008 command prompt.

As far as being much help in actually writing a module, I'm not there yet in my knowledge of how it all works. There is the module developers mailing list I think, I'm sure they could help you out.
Back to top


Reply to topic   Topic: unable to complie a sample code for a module View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules