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 -> Building & Member Downloads View previous topic :: View next topic
Reply to topic   Topic: Compiling modules with apxs.bat assumes 32-bit platform
Author
deltamind106



Joined: 22 Aug 2012
Posts: 9
Location: Boston, USA

PostPosted: Wed 22 Aug '12 21:37    Post subject: Compiling modules with apxs.bat assumes 32-bit platform Reply with quote

I am building my own Apache 2.4 module and am using the binaries from this site on the Windows x64 platform. I downloaded the "apxs_win32.zip" from this site, which is supposed to provide apxs.bat to compile & link external modules with all the correct flags.

First thing I noticed is that the apxs_win32.zip archive hasn't been updated since 2007, so it is over 5 years old.

I ran the required installation command "perl Configure.pl", and then tried to use the resulting "apxs.bat" script. It failed because all the ".bat" and ".pl" scripts unconditionally include a linker option "/machine:I386", and I am building with the VC-10 64-bit compiler, against an "x64" version of Apache.

I also noticed that the file "build/config_vars.mk" has a line that includes the option "/machine:I386" in the LDFLAGS variable. This was the way it was when I downloaded the 64-bit version of Apache 2.4.3. I had to change this to "/machine:x64" to get "apxs.bat" to work.

It seems like it's time to refresh the apxs_win32.zip archive with some fixes. I would suggest the following:

1. Check to see whether "httpd.exe" was built to run in 32 or 64 bit mode. If 32 bit mode use "/machine:I386", if 64 bit mode use "/machine:x64".

2. The script assumes the name of the Apache executable is "Apache.exe", which was the convention a long time ago. Nowadays it uses "httpd.exe", so this should really be the default (although you can override the default with the --with-apache-prog option).

I know very little about the PERL programming language (in fact, I hate PERL with a passion). Otherwise I would do the patch myself. It probably makes sense for someone familiar with PERL to do the patch.

Thank you,
-Eric Johanson
Back to top
glsmith
Moderator


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

PostPosted: Wed 22 Aug '12 22:32    Post subject: Reply with quote

It's just as easy to build modules without it at the command line. All it does is generate a makefile.
Back to top
deltamind106



Joined: 22 Aug 2012
Posts: 9
Location: Boston, USA

PostPosted: Wed 22 Aug '12 22:37    Post subject: Reply with quote

glsmith wrote:
It's just as easy to build modules without it at the command line. All it does is generate a makefile.

I'm not sure what you're talking about. "apxs.bat" does not generate makefiles. It invokes "cl.exe" and then invokes "link.exe".

What is the "apxs.bat" command that you've used that caused it to generate a makefile?
Back to top
glsmith
Moderator


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

PostPosted: Thu 23 Aug '12 3:52    Post subject: Reply with quote

My recollection is probably wrong as I haven't used it in forever but I thought I remembered having to use nmake after it. I find it easier to not use it, especially since I am building for both x86 and x64 as well as different versions of Apache in most cases.
Back to top
deltamind106



Joined: 22 Aug 2012
Posts: 9
Location: Boston, USA

PostPosted: Thu 23 Aug '12 4:37    Post subject: Reply with quote

glsmith wrote:
My recollection is probably wrong as I haven't used it in forever but I thought I remembered having to use nmake after it. I find it easier to not use it, especially since I am building for both x86 and x64 as well as different versions of Apache in most cases.

No, you don't use nmake after running apxs.bat. To compile module mod_try.c, you just run:

apxs.bat -c mod_try.c

And it's supposed to result in the file mod_try.so. It works for 32-bit apache, but not for 64-bit. The reason is because the option "/machine:IX386" is scattered throughout the following files:

bin/apxs.bat
bin/apxs.pl
build/config_vars.mk

Building a module another way is certainly possible, but it's just asking for unnecessary complexity because you have to manually script all the compiler and linker options for the target platform. And then if (when) the options change in a future version or different platform, you have to keep your build script updated. The apxs script (in both Unix and Windows) is supposed to hide all that error-prone detail from you.

-Eric
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Thu 23 Aug '12 10:34    Post subject: Reply with quote

Like with building without using apxs you have first to remove all /MACHINE: tags with the following Perl command in the Apache source:

Code:
FOR /R %F IN (*.mak *.mk.win) DO perl -pi.bak -e "s/\/MACHINE:X[0-9]*//gi" %F


For httpd.exe, see the Readme in the apxs_win32.zip here at the additional download page. No need to change that in the script. It states:

If you are building for Apache 2.1-dev/2.2, you will discover
that it's now httpd.exe, not Apache.exe. Specifying

perl Configure.pl --with-apache-prog=httpd.exe

will provide the results you hoped for.



Steffen
Back to top
deltamind106



Joined: 22 Aug 2012
Posts: 9
Location: Boston, USA

PostPosted: Thu 23 Aug '12 14:11    Post subject: Reply with quote

Yes I saw the README regarding the changing the name of the Apache executable with the --with-apache-prog option (as I already mentioned). It just seems like the "default" should now be "httpd.exe" since the name "Apache.exe" hasn't been used in years.

Are you saying the problem with the "/machine:I386" option is a bug in the original Windows Apache distribution? If so, can't that be fixed in the distribution itself, rather than having developers fix it every time they download it?

Also, it's not enough to fix *.mak *.mk.win (actually I did not fix any such files). You have to fix build/config_vars.mk.

And, the apxs_win32.zip download pack has a bunch of files that also have "/machine:I386" in it. Can we remove those instances of the option, and re-code the logic so that it determines the correct /machine option from the Apache distribution?

-Eric
Back to top


Reply to topic   Topic: Compiling modules with apxs.bat assumes 32-bit platform View previous topic :: View next topic
Post new topic   Forum Index -> Building & Member Downloads