Author |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 4:06 Post subject: Has anyone created a simple mod from scratch on win32? |
|
|
I tried to get the default example mod_foo.c to work, but I get these link errors:
C:\atest\foo>apxs -c -i -a mod_foo.c
cl /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\Apache2\include"
/c /Fomod_foo.lo mod_foo.c
mod_foo.c
link kernel32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"C:\Apa
che2\lib" /out:mod_foo.so mod_foo.lo
Creating library mod_foo.lib and object mod_foo.exp
mod_foo.lo : error LNK2019: unresolved external symbol __imp__ap_rputs@8 referen
ced in function _foo_handler
mod_foo.lo : error LNK2019: unresolved external symbol __imp__ap_hook_handler@16
referenced in function _foo_register_hooks
mod_foo.so : fatal error LNK1120: 2 unresolved externals
apxs:Error: Command failed with rc=6291456
Can anyone steer me in the right direction?
My apache is set up for mod_so. I compiled Apache 2.2.3 on windows xp
at the command prompt, because using Express C++ was a nightmare. |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Tue 07 Nov '06 5:37 Post subject: |
|
|
If you are using the apxs for Windows (from the Apache Lounge download area) - try adding the names of the Apache and APR libraries to your apxs command:
Code: | apxs -c -i -a mod_foo.c libapr-1.lib libaprutil-1.lib libapriconv-1.lib libhttpd.lib |
The four libraries which start with "lib" are the ones you will most often need to build modules. Quote: | Directory of C:\Apache2\lib\*.lib
09/28/2006 09:19a 1,377,454 apr-1.lib
09/28/2006 09:22a 1,245,064 aprutil-1.lib
09/28/2006 09:20a 93,360 libapr-1.lib
09/28/2006 09:20a 7,554 libapriconv-1.lib
09/28/2006 09:23a 52,002 libaprutil-1.lib
10/04/2006 07:25a 102,790 libhttpd.lib
09/28/2006 09:22a 441,982 xml.lib |
If your module calls any functions named "XML_something", you may also need xml.lib.
-tom- |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 5:47 Post subject: That seems to have done it! |
|
|
Tom,
I just ran what you suggested. Here is the output:
C:\atest\foo>apxs -c -i -a mod_foo.c libapr-1.lib libaprutil-1.lib libapriconv-1
.lib libhttpd.lib
cl /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\Apache2\include"
/c /Fomod_foo.lo mod_foo.c
mod_foo.c
link kernel32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"C:\Apa
che2\lib" /out:mod_foo.so mod_foo.lo libapr-1.lib libaprutil-1.lib libapricon
v-1.lib libhttpd.lib
Creating library mod_foo.lib and object mod_foo.exp
C:\Perl\bin\perl.EXE -MExtUtils::Command -e cp mod_foo.so C:\Apache2\modules
C:\Perl\bin\perl.EXE -MExtUtils::Command -e chmod 755 C:\Apache2\modules\mod_foo
.so
C:\Perl\bin\perl.EXE -MExtUtils::Command -e cp mod_foo.lib C:\Apache2\lib
C:\Perl\bin\perl.EXE -MExtUtils::Command -e chmod 755 C:\Apache2\lib\mod_foo.lib
[activating module `foo' in C:\Apache2\conf\httpd.conf][color=blue]
Thanks for the info. I would not have found these references otherwise!
|
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 16:17 Post subject: |
|
|
Hi,
I spoke prematurely...I get this error now when I invoke httpd at the command prompt:
RuntimeError!
Program:c:\apache2\bin\httpd.exe
R6034
An application has made an attempt to load the C runtime library incorrectly.
In the directory c:\apache2\modules there is the file mod_foo.so
but there is no mod_foo.pdb file. All of the other *.so files have corresponding *.pdb files
What is with that? Do I need this pdb creature?
Also, mod_foo.lib now appears also in \apache2\lib.
I am not loading something...
Thanks again! |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 16:28 Post subject: |
|
|
Here is error result after the windows error dialog disappears:
C:\>httpd
httpd: Syntax error on line 115 of C:/Apache2/conf/httpd.conf: Cannot load C:/Apache2/modules/mod_foo.so into server: A dynamic link library (DLL) initialization routine failed. |
|
Back to top |
|
Jorge
Joined: 12 Mar 2006 Posts: 376 Location: Belgium
|
Posted: Tue 07 Nov '06 18:06 Post subject: |
|
|
bruciebruce wrote: |
What is with that? Do I need this pdb creature?
|
pdb files contain debug information, you don't need them and i remove them from my system. And when i need to debug I use a different apache instant anyway. |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 19:06 Post subject: |
|
|
I remember this error number from microsofty before when I was struggling
with the "regular" apache build. It had to do with the non-existence of a manifest file. I tried copying the mod_foo manifest to different locations in my apache tree but without any new results. |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Tue 07 Nov '06 21:03 Post subject: |
|
|
I suggest you try building modules/echo/mod_echo.c using the command Code: | apxs -c -i -a mod_echo.c libapr-1.lib libaprutil-1.lib libapriconv-1.lib libhttpd.lib | and see if you have the same problem.
FYI - here are some directives to set up mod_echo on port 81 for connections from localhost Code: | LoadModule echo_module "modules/mod_echo.so"
<IfModule echo_module>
Listen localhost:81
<VirtualHost localhost:81>
ProtocolEcho On
</VirtualHost>
</IfModule> |
To test mod_echo, you can use telnet to port 81. Each line you type should be echoed: Quote: | C:\> telnet localhost 81
hello
goodbye
ctrl-] quit
C:\> |
If mod_echo does not have the same problem, then it is probably something in your mod_foo code.
Is mod_foo your own code or did you download it from somewhere?
-tom- |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 21:27 Post subject: |
|
|
I will try what you suggested...
Here is how I generated mod_foo.c
apxs -g -n foo
to quote,
"Template Generation Options
-g
This generates a subdirectory name (see option -n) and there two files: A sample module source file named mod_name.c which can be used as a template for creating your own modules or as a quick start for playing with the apxs mechanism. And a corresponding Makefile for even easier build and installing of this module. "
Thx again!! |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 21:49 Post subject: |
|
|
Hi again,
I get exactly the same error. I guess I should read up this stuff...
C:\atest\echo>httpd
httpd: Syntax error on line 116 of C:/Apache2/conf/httpd.conf: Cannot load C:/Apache2/modules/mod_echo.so into server: A dynamic link library (DLL) initialization routine failed. |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Tue 07 Nov '06 22:36 Post subject: |
|
|
There should be more info about the error in the windows Event Viewer.
Steffen |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 22:54 Post subject: |
|
|
Steffen,
Nothing is either put into the application or system event viewer console after
this is invoked.
-B |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Tue 07 Nov '06 23:36 Post subject: |
|
|
Often that error means that mod_foo.so depends on a .dll which cannot be found.
If you have installed the Platform SDK, it has a Dependency Walker utility which is helpful for problems like this.
The default location for it is
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin\Depends.exe
You shouldmake sure only the correct Apache /bin directory is in your PATH
C:\> Depends.exe C:\Apache2\modules\mod_foo.so to check which DLLs are required by mod_foo.so. Use F9 to show the full path of these DLLs.
You should expect to see libhttpd.dll and MSVCR80.dll as dependencies with a minimal module if you haven't added any code to it yet.
Hope this helps.
-tom- |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Tue 07 Nov '06 23:38 Post subject: |
|
|
Do you use Visual c++ 2005 to build the mod ?
The Apache you are running is also build with Visual c++ 2005 ?
Steffen |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 23:44 Post subject: |
|
|
Steffen,
I used the advice that I found here on your forum to build Apache 2.2.3 at the command prompt but had link problems within Express C++ (and so gave up on using the IDE).
This is XP Pro Bug Fix 2 (oops is that a Service Pack? (lol)) |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Tue 07 Nov '06 23:58 Post subject: |
|
|
Tom,
That is some cool tool!
Those files you wanted are there. The only error involved a missing msjava.dll which I can't see as being relevant.
The bottom part of the screen said this:
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
But...these are just warnings.
Humm.... |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Wed 08 Nov '06 0:01 Post subject: |
|
|
Tom,
Should I not be linking with the kernel32.lib or is this a lame question?
-B |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Wed 08 Nov '06 15:12 Post subject: |
|
|
msjava.dll? Yikes! Where did that come from?
Linking with kernel32.lib shouldn't cause any problems, but that Windows library is usually implicit - you shouldn't need to specify it directly.
A couple of possibilities:
You have something in your PATH, LIB, or INCLUDE environment variables which causes this to be linked into mod_foo
One of these variables included some software which uses a different version of the APR (Apache Portable Runtime) when you built mod_foo.
Your PATH env var includes some software which uses a different version of the APR when you start httpd.exe.
My post Another set of VC++ 2005 command-line build instructions shows what should be in these vars when you build Apache (or when you build modules).
You won't need GnuWin32, MinGW, or NASM to build a module - but check that you don't have something else in there which is causing this dependency.
-tom- |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Wed 08 Nov '06 20:25 Post subject: |
|
|
Tom,
Here is my devel path that I used for building apache 2.2.3 and compiling mod_foo
Path=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin;C:\P
rogram Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin\WinNT;C:\Prog
ram Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visua
l Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools;C:\Pr
ogram Files\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Fram
ework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;C:\mas
m32\bin;C:\awk;C:\Perl\bin;C:\apps\php-5.1.6;C:\apps\jdk1.5.0_06\bin;C:\apps\Act
iveState Komodo 3.5\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\
Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Microsoft SQL
Server\80\Tools\BINN;C:\apps\Python24;C:\apps\Django-0.91\django\bin;C:\devel\an
t\apache-ant-1.6.5\bin;C:\devel\clisp-2.39;C:\Apache2\bin;C:\apps\libtool\bin;C:
\Program Files\Novosoft\C2J\Bin;C:\devel\jwsdp-1.6\jwsdp-shared\bin;C:\devel\jws
dp-1.6\jwsdp-shared\bin;C:\devel\jwsdp-1.6\jwsdp-shared\bin;C:\apps\curl;
Here is my "normal" path that I use to invoke httpd
Path=C:\masm32\bin;C:\awk;C:\Perl\bin;C:\apps\php-5.1.6;C:\apps\jdk1.5.0_06\bin;
C:\apps\ActiveState Komodo 3.5\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System
32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Mic
rosoft SQL Server\80\Tools\BINN;C:\apps\Python24;C:\apps\Django-0.91\django\bin;
C:\devel\ant\apache-ant-1.6.5\bin;C:\devel\clisp-2.39;C:\Apache2\bin;C:\apps\lib
tool\bin;C:\Program Files\Novosoft\C2J\Bin;C:\devel\jwsdp-1.6\jwsdp-shared\bin;C
:\devel\jwsdp-1.6\jwsdp-shared\bin;C:\devel\jwsdp-1.6\jwsdp-shared\bin;C:\apps\c
url;
Both of these were gotten from a "set" at the command prompt (and not
by using the control panel...). |
|
Back to top |
|
bruciebruce
Joined: 07 Nov 2006 Posts: 15 Location: On the beach in SoCal
|
Posted: Wed 08 Nov '06 20:46 Post subject: |
|
|
I notice now that the manifests are different for httpd and mod_foo for the VC80 ... CRT file.
mod_foo.so.manifest :
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
and for httpd.exe.manifest
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
Is this an "issue"? |
|
Back to top |
|