DevHeads.net

building httpd 2.4 on windows x64

I've been trying to digest and understand all the details of building
apache httpd 2.4 on windows x64.
I tried to build it (along with pcre, openssl and zlib) as 64-bit and
got stuck when the build failed in visual studio 2010 after adding a x64
configuration to target.

A bit of digging and I came across this:
<a href="http://www.apachelounge.com/viewtopic.php?t=5877" title="http://www.apachelounge.com/viewtopic.php?t=5877">http://www.apachelounge.com/viewtopic.php?t=5877</a>

Which has this post from Gregg Smith:

I'll admit flat out that I'm not a windows person at all and loathe
having to do anything on the platform but unfortunately don't have much
of a choice :). But I can follow a recipe and generally dig in and
understand what's going on fairly well.

I'd like to try to avoid having to actually rely on the artifacts
generated by Gregg because I don't like having the "single point of
failure".

Does anyone actually have a recipe, or something to explain to a windows
newbie what has to be done to generate the same artifacts so I can learn
this myself? Is it possible, or does it make sense that the httpd
project try to include his script to convert the projects in the same
way that cvtdsp.pl is included with apr?

I did take a quick look at cmake. I'm not sure if it'll solve the
problem but unfortunately we need mod_charset_lite, so that pretty much
rules out cmake for now.

Thanks,
Andy

Comments

Re: building httpd 2.4 on windows x64

By Andy Wang at 02/27/2015 - 13:43

I've given up trying to figure out how to do this with visual studio in
a reproducible fashion and started looking at cmake.

Has anyone had any luck building
httpd (2.4.12 is what I'm using) with the following dependencies using
cmake:
openssl
zlib
pcre
apr
and apr-util?

I'm able to build zlib, pcre, openssl, and apr and have them installed
into C:\Apache24
but I'm stuck on apr-util. It's looking for openssl but I don't know
how to tell it to find the openssl that I've installed into C:\Apache24.

I've tried setting the OPENSSL_ROOT_DIR environment variable (it looks
like Cmake is trying to use that) but no luck. Anyone have any luck
with this?

I need to use our own openssl build and can't depend on a third party
build (which it looks like cmake wil attempt to find).

Thanks,
Andy

Re: building httpd 2.4 on windows x64

By Jeff Trawick at 02/27/2015 - 14:09

I need to update apr-util's README.cmake file with this blurb from httpd.
Does this fix your issue?

OpenSSL
If you have a binary install of OpenSSL in a well-known directory (e.g.,
%HOME%\OpenSSL-Win64) and you wish to build httpd against a different
install of OpenSSL, the cmake build may unexpectedly select OpenSSL
libraries in the well-known directory even if the expected include files
are used. Check the cmake output from your httpd build to confirm that
the expected OpenSSL libraries and include files are used.

The cmake FindOpenSSL module searches for OpenSSL libraries in a "VC"
subdirectory of the OpenSSL install with filenames that indicate the build
type (e.g., "<PREFIX>/lib/VC/ssleay32MD.lib"); defining CMAKE_PREFIX_PATH
or OPENSSL_ROOT_DIR or even OPENSSL_LIBRARIES does not circumvent finding
these libraries.

To work around this issue, rename the well-known OpenSSL directory while
building httpd. Let us know if you find a better solution.

Re: building httpd 2.4 on windows x64

By Andy Wang at 02/27/2015 - 14:37

On 02/27/2015 12:09 PM, Jeff Trawick wrote:
Yes and no. I saw that in the httpd blurb and tried to wrap my head
around it.

I don't have a well-known openssl install so cmake isn't even finding an
openssl install. So the first paragraph of that blurb (I think?)
doesn't apply to me.

I tried setting OPENSSL_ROOT_DIR, but I think I misunderstood the second
paragraph. I misinterpreted the VC bit. I'll try putting the lib files
in my openssl_root_dir/lib/VC and see if I can make that work.

Thanks,
Andy

Re: building httpd 2.4 on windows x64

By Jeff Trawick at 02/27/2015 - 15:09

I doubt that would be useful, although it is where the odd FindOPENSSL
implementation will look.

Did you set OPENSSL_ROOT_DIR on the cmake command-line, as
-DOPENSSL_ROOT_DIR=c:\Users\Foo\install\openssl_1.0.1 or similar?

Re: building httpd 2.4 on windows x64

By Fred Duarte at 02/27/2015 - 17:49

Unsuscribe

2015-02-27 14:09 GMT-05:00 Jeff Trawick < ... at gmail dot com>:

Re: building httpd 2.4 on windows x64

By Andy Wang at 02/27/2015 - 15:29

So yeah, that didn't work.

I tried both -DOPENSSL_ROOT_DIR=C:\Apache24 (this is where I did the
nmake -f ms/ntdll.mak install into) and setting OPENSSL_ROOT_DIR
environment variable.

I've also just for the hell of it, tried using OPENSSL_ROOT_DIR to the
openssl src tree with a built openssl.

None of those works.

This is what happens when i try to run cmake:

CMake Error at
C:/bin/cmake/share/cmake-2.8/Modules/FindOpenSSL.cmake:278 (list)
:
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:22 (FIND_PACKAGE)

CMake Error at
C:/bin/cmake/share/cmake-2.8/Modules/FindOpenSSL.cmake:279 (list)
:
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:22 (FIND_PACKAGE)

CMake Error at
C:/bin/cmake/share/cmake-2.8/Modules/FindOpenSSL.cmake:281 (list)
:
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:22 (FIND_PACKAGE)

CMake Error at
C:/bin/cmake/share/cmake-2.8/Modules/FindOpenSSL.cmake:283 (list)
:
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:22 (FIND_PACKAGE)

Re: building httpd 2.4 on windows x64

By Jeff Trawick at 02/27/2015 - 15:43

What's the exact cmake version you're using?

Re: building httpd 2.4 on windows x64

By Andy Wang at 02/27/2015 - 15:53

I'm using cmake 2.8.10.2. I already had it on the system and since it
was later than the required version I stuck with it. I'm more than
happy to try the latest 3.x one if you think it'll help.

So this is the part where I admit I'm completely new at cmake and really
pretty much doing any native development on windows. So I used the gui
to do the initial generation, and then afterwards used the command line
to make minor -D tweaks.

Is there a specific file that has details that would answer how I
invoked cmake or should I start over using cmake from the cli? If that
helps, I'd be more than happy to do so.

Thanks,
Andy

Re: building httpd 2.4 on windows x64

By Jeff Trawick at 02/27/2015 - 16:25

My knowledge about this is very fuzzy, but I "understand" that decisions
get saved in the cache dir, and they aren't always updated by subsequent
invocations. I start over with a fresh build directory when changing any
settings, although that may be overkill.

I'd start over, use only the CLI, and always invoke cmake from a script
(e.g., .cmd file) that has the options you're using so you always know how
you last ran it.

Here's how I build apr-util:

cd fresh build dir
cmake -DCMAKE_INSTALL_PREFIX=c:\install-path -G "NMake Makefiles"
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DAPU_HAVE_CRYPTO=ON (other uninteresting
options) c:\path-to-apr-util-sources

When this runs, OpenSSL and APR and other support libraries have already
been installed to c:\install-path

Re: building httpd 2.4 on windows x64

By Andy Wang at 02/27/2015 - 18:11

On 02/27/2015 02:25 PM, Jeff Trawick wrote:
Before I continue, I'd like to say thanks for the help. The handful of
responses from you have really helped me focus quite a bit more on what
to look at for this and I appreciate it.

That said, I'm an idiot. I jumped the gun and was trying to use openssl
1.0.2.

I switched to openssl 1.0.1l and it just worked.

I did find another problem. I decided to try cmake 3.1.3 too just to
see. Its generated Makefiles for apr didn't build apr-1.pdb.
Backed down to 2.8.10.2 and all good.

So something is broken there.

But now I have openssl, pcre, apr, apr-util all figured out. zlib
(which doesn't have an install target - should be easy enough to figure
out manually) and httpd left to build.

Thanks again.
Andy

Re: building httpd 2.4 on windows x64

By Jeff Trawick at 02/28/2015 - 08:26

Weird... I built with some OpenSSL 1.0.2 betas without problems, always
like this:

OPENSSL_BUILDDIR := $(TOP_BUILDDIR)\openssl
OPENSSL_CONFIGURE_OPTS := no-asm --prefix=$(PREFIX) VC-WIN64A

mkdir $(OPENSSL_BUILDDIR)
cd $(OPENSSL_BUILDDIR) && gzip -dc
$(DOWNLOADS)\openssl-$(OPENSSL_VER).tar.gz | tar -xf -
cd $(OPENSSL_BUILDDIR)\openssl-$(OPENSSL_VER) && perl Configure
$(OPENSSL_CONFIGURE_OPTS)
cd $(OPENSSL_BUILDDIR)\openssl-$(OPENSSL_VER) && ms\do_win64a.bat
cd $(OPENSSL_BUILDDIR)\openssl-$(OPENSSL_VER) && nmake /f ms\ntdll.mak
cd $(OPENSSL_BUILDDIR)\openssl-$(OPENSSL_VER) && nmake /f ms\ntdll.mak test
cd $(OPENSSL_BUILDDIR)\openssl-$(OPENSSL_VER) && nmake /f ms\ntdll.mak
install

Possibly I will have time to play with those further (possibly not).

FWIW, I don't have any issues building zlib 1.2.8 with its included cmake
support, which results in a working "nmake install".

Re: building httpd 2.4 on windows x64

By Andy Wang at 03/02/2015 - 12:51

On 02/28/2015 06:26 AM, Jeff Trawick wrote:
Yeah, I tested this multiple times and as soon as I go with openssl
1.0.2 I got the same apr-util configuration error.

I had other problems with anything newer than 2.8.10.2. pcretest was
crashing with a stack overflow (some googling seemed to imply this was a
link option issue with stack size). Occurred with 2.8.12.2, 3.0.2 and
3.1.3. It didn't occur with 2.8.10.2 so I just stuck with that. Not an
httpd problem, but I thought I'd mention it.

Yeah, I discovered after my last message that zlib had cmake support.
It's broken for AMD64 option, but I found a patch on on the zlib git
repo that fixed it.
<a href="https://github.com/mastermind-/zlib/commit/3d1dd53460e146502a77019a35de79a78ccbea74" title="https://github.com/mastermind-/zlib/commit/3d1dd53460e146502a77019a35de79a78ccbea74">https://github.com/mastermind-/zlib/commit/3d1dd53460e146502a77019a35de7...</a>

This is nice, I now have a fully scripted windows httpd build along with
all of it's dependencies openssl, zlib, pcre, apr and apr-util.

Is it wrong that the build script is a .sh script running under cygwin? :)

This is awesome. Once again thanks so much for the the help and pushes
in the right direction.

Andy

Re: building httpd 2.4 on windows x64

By Andy Wang at 03/03/2015 - 12:41

I hate coming across mail threads in google without some amount of
helpful detail in a "final" summary post. So here's that, in case
someone else in the future runs across this hopefully this will be helpful:

Here's how I built everything:
openssl - as mentioned previously in the thread, was unable to get cmake
to detect openssl 1.0.2:
perl Configure VC-WIN64A --prefix=$PREFIX
ms/do_win64a.bat
nmake -f ms/ntdll.mak
nmake -f ms/ntdll.mak test
nmake -f ms/ntdll.mak install

zlib:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DAMD64=ON $ZLIB_SRCDIR
nmake
nmake test
nmake install

note: zlib with AMD64 on fails to link. This is currently not fixed as
of 1.2.8. There is a fix in github:
<a href="https://github.com/madler/zlib/pull/72" title="https://github.com/madler/zlib/pull/72">https://github.com/madler/zlib/pull/72</a>

pcre:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON
-DPCRE_BUILD_PCRECPP=OFF -DPCRE_BUILD_PCREGREP=OFF -DPCRE_SUPPORT_UTF=ON
$PCRE_SRCDIR
nmake
nmake test
nmake install

apr:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DAPR_INSTALL_PRIVATE_H=ON $APR_SRCDIR
nmake
nmake install

apr-util:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DOPENSSL_ROOT_DIR=$PREFIX -DAPU_HAVE_CRYPTO=ON
-DCMAKE_BUILD_TYPE=RelWithDebInfo $APRUTIL_SRCDIR
nmake
nmake install

httpd:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_MODULES=i $HTTPD_SRCDIR
nmake
nmake install

$PREFIX is the same location

And yes, $PREFIX not %PREFIX%. My build script is a bash script :)

This is much much much more reproducible and automatable than the visual
studio build process.

Couple of caveats:
I could not get apr to build the apr-1.pdb file with cmake 3.1.3

nmake test in pcre stack overflows with any version of cmake newer than
2.8.10.2. I didn't bother to figure out why as 2.8.10.2 works fine for me.

RE: building httpd 2.4 on windows x64

By Andy Wang at 03/03/2015 - 17:05

Yup, pcretest is failing on Test 2 with a stack overflow which is to be expected when the stack is too small (as it is on windows - default 1MB).

So I modified my script to simply ignore PCRE tests.

cmake 3.1.3 supports openssl 1.0.2 but for some reason it breaks make install of apr as it's looking for apr-1.pdb (it's a static lib though, so why is it looking for that)? I solved it by setting INSTALL_PDB=OFF and manually copying libapr-1.pdb to $PREFIX/bin

So I have everything working with cmake 3.1.3 also.

Andy

I hate coming across mail threads in google without some amount of
helpful detail in a "final" summary post. So here's that, in case
someone else in the future runs across this hopefully this will be helpful:

Here's how I built everything:
openssl - as mentioned previously in the thread, was unable to get cmake
to detect openssl 1.0.2:
perl Configure VC-WIN64A --prefix=$PREFIX
ms/do_win64a.bat
nmake -f ms/ntdll.mak
nmake -f ms/ntdll.mak test
nmake -f ms/ntdll.mak install

zlib:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DAMD64=ON $ZLIB_SRCDIR
nmake
nmake test
nmake install

note: zlib with AMD64 on fails to link. This is currently not fixed as
of 1.2.8. There is a fix in github:
<a href="https://github.com/madler/zlib/pull/72" title="https://github.com/madler/zlib/pull/72">https://github.com/madler/zlib/pull/72</a>

pcre:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON
-DPCRE_BUILD_PCRECPP=OFF -DPCRE_BUILD_PCREGREP=OFF -DPCRE_SUPPORT_UTF=ON
$PCRE_SRCDIR
nmake
nmake test
nmake install

apr:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DAPR_INSTALL_PRIVATE_H=ON $APR_SRCDIR
nmake
nmake install

apr-util:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DOPENSSL_ROOT_DIR=$PREFIX -DAPU_HAVE_CRYPTO=ON
-DCMAKE_BUILD_TYPE=RelWithDebInfo $APRUTIL_SRCDIR
nmake
nmake install

httpd:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_MODULES=i $HTTPD_SRCDIR
nmake
nmake install

$PREFIX is the same location

And yes, $PREFIX not %PREFIX%. My build script is a bash script :)

This is much much much more reproducible and automatable than the visual
studio build process.

Couple of caveats:
I could not get apr to build the apr-1.pdb file with cmake 3.1.3

nmake test in pcre stack overflows with any version of cmake newer than
2.8.10.2. I didn't bother to figure out why as 2.8.10.2 works fine for me.

Re: building httpd 2.4 on windows x64

By Jeff Trawick at 03/04/2015 - 08:24

I'm sorry that I didn't remember this before: The code that tried to copy
apr-1.pdb has already been removed in apr development levels; that will be
reflected in the next apr 1.5.x release. (Older cmake would create the
file, and I didn't catch its lack utility until testing with cmake 3.
Whoops.)

Thanks for your great summary!