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: Building Apache 2.4.12 Windows x64 with cmake
Author
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Thu 26 Feb '15 22:15    Post subject: Building Apache 2.4.12 Windows x64 with cmake Reply with quote

Disclaimer: Windows build newbie here. I'm a straight up unix guy.

I'm trying to build a 64-bit Apache 2.4.12 with zlib, openssl, pcre, apr, and apr-util.

I honestly have no idea what I'm doing. I'd like to build a single deployable bundle (similar too the way the visual studio projects for apache builds) so I've done the following:
1) compiled openssl using make. changed:
INSTALLTOP
OPENSSLDIR
to C:/Apache24 to install the openssl files into C:/Apache24
2) used cmake and nmake to build pcre and installed to C:/Apache24
3) compiled zlib using nmake. However, zlib has no install target so I have no idea how to install it. Looking at the previous projects I was thinking I could manually copy the lib, dll/pdb and h files to the various directories under C:/Apache24 - skipped this for now though.
4) used cmake and nmake to build apr and installed to C:/Apache24
5) trying to use cmake to configure apr-util. I've set APR_INCLUDE_DIR and APR_LIBRARIES to point to the C:/Apache24 location, but cmake still complains:

Code:
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)




APR-Util configuration summary:

  Build type ...................... : Release
  Install .pdb (if available)...... : ON
  Install prefix .................. : C:/Apache24
  C compiler ...................... : c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/amd64/cl.exe
  APR include directory ........... : C:/Apache24/include
  APR libraries ................... : C:/Apache24/lib/libapr-1.lib
  DBD ODBC driver ................. : ON
  APU_HAVE_CRYPTO ................. : OFF
  APR_HAS_LDAP .................... : ON
  Build test suite ................ : OFF
    (testing dynamic libraries)
Configuring incomplete, errors occurred!


I have no idea how to get the thing to find my openssl that's in C:/Apache24
I've tried to set OPENSSL_ROOT_DIR environment variable and tried passing it in as -DOPENSSL_ROOT_DIR and that hasn't worked.

Any thoughts on where to go?

Thanks
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 27 Feb '15 0:37    Post subject: Re: Building Apache 2.4.12 Windows x64 with cmake Reply with quote

Below the Apache build directory there should be a subdir srclib with subdirectories: apr, apr-iconv, apr-util, openssl, pcre and zlib.

Openssl should be compiled, with filled subdirs openssl\out32 and openssl\out32dll.

That is the way it works with the makefiles. Maybe CMake uses the same directory tree.

FWIW: CMake happens to be quite clever at finding openssl: it once found my Openssl in \OpenSSL\Win32\1_0_1i. If the directory tree below srcdir does not work, just put openssl in C:\openssl. Probably CMake will find it there.

For a Windows newbie: Win7+ is capable of making directory symlinks. I always put the wanted version of opensll below srclib with a batch file containing

cd srclib
rd openssl
mklink /D openssl \openssl\opensslvc11.x64

This way I can easily switch from building for x86 and x64 without recompiling open ssl every time.
Back to top
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Fri 27 Feb '15 1:01    Post subject: Reply with quote

The README.cmake documentation is pretty clear that cmake doesn't use the srclib mechanism but instead relies on the dependencies needing to be built and installed.

The problem with your idea of putting openssl somewhere else is I'd really need to build a self-contained redistributable apache, including all the dependencies. Kind of like how the current visual studio build process does it. Having to build openssl into another location defeats that purpose. One possibility I had considered was installing it into some location that the cmake locator can find it in but then installing it into the apache directory again afterward but that seems silly and it seems like it should be unnecessary.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 27 Feb '15 1:26    Post subject: Reply with quote

CMake needs the OpenSSL *.libs in openssl\out32dll to link apache to the ssl DLL's at compile time. You do not have to distribute the whole openssl source tree. That would be really silly. Just copy the necessary files after compiling in the apache\bin directory. The VC-builds tell you which files to use.

BTW: what is so special about you setup that you cannot use the Apachelounge downloads? It is perfectly possible to use those for your purpose, I think.
Back to top
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Fri 27 Feb '15 12:10    Post subject: Reply with quote

I'm not talking about distributing the entire openssl source tree. I'm talking about the built openssl tree (make install, libraries, openssl.exe, include files, etc).

Yes, I know that I can copy what I need manually, but what I'm looking for is a proper way of doing this. The documentation for the httpd cmake build is unfortunately not very clear, nor is it very thorough.

I can't use the apachelounge builds because this is our custom "fork" of httpd. We have numerous patches for our own purposes that don't make sense upstream and thus we maintain them ourselves.

I'll try the srclib trick. See if that works.
Back to top
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Fri 27 Feb '15 15:33    Post subject: Reply with quote

So I started thinking about how to do this, and I'm not sure how this would work.

The apache cmake build requires that the dependencies are built (apr, apr-util, openssl, zlib).

my problem is, I can build openssl, zlib and apr-util.

But how do I make apr-util see openssl?

Using srclib does not work. apr-util does not see openssl in srclib (which sort of makes sense, how would it as it's a separate build of it's own).

Just curious, but have you actually done this build?
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 27 Feb '15 16:28    Post subject: Reply with quote

wangmaster wrote:
So I started thinking about how to do this, and I'm not sure how this would work.

The apache cmake build requires that the dependencies are built (apr, apr-util, openssl, zlib).

my problem is, I can build openssl, zlib and apr-util.

But how do I make apr-util see openssl?

CMake should do the job for you.
Quotes from the CMakeLists.txt of apr-util:

FIND_PACKAGE(OpenSSL)

and further on

IF(NOT OPENSSL_FOUND)
MESSAGE(FATAL_ERROR "Only OpenSSL-based crypto is currently implemented in the cmake build")
ENDIF()

I wonder how you did build apr-util without OpenSSL. The CMakeLists.txt says you cannot. Did not you use that?

Quote:
Using srclib does not work. apr-util does not see openssl in srclib (which sort of makes sense, how would it as it's a separate build of it's own).

When you stated that apr-util needed OpenSSL, I was really surprised. It does not when you are using dsw/vcproj/vcxproj or makefiles. Only then did I see that CMake requires it for apr-util.

Quote:
Just curious, but have you actually done this build?

Not with CMake but with a VC11 project that was generated by converting Apache.dsw. I needed that to build the mod_ssl with OpenSSL-fips:
http://www.apachelounge.com/viewtopic.php?t=6197
Back to top
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Fri 27 Feb '15 17:09    Post subject: Reply with quote

Jan-E wrote:

CMake should do the job for you.
Quotes from the CMakeLists.txt of apr-util:

FIND_PACKAGE(OpenSSL)

and further on

IF(NOT OPENSSL_FOUND)
MESSAGE(FATAL_ERROR "Only OpenSSL-based crypto is currently implemented in the cmake build")
ENDIF()

I wonder how you did build apr-util without OpenSSL. The CMakeLists.txt says you cannot. Did not you use that?


This is the problem. I haven't been able to build apr-util because I can't make it find my openssl. And I want to figure out how to make it find my openssl without having to install openssl in a particular location (one of the common locations that the CMAKe openssl locator uses). This is where I'm hung up on. I'd like to try to figure out how to tell cmake to use an openssl of my choosing.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 27 Feb '15 17:14    Post subject: Reply with quote

Install https://slproweb.com/download/Win64OpenSSL-1_0_1L.exe from https://slproweb.com/products/Win32OpenSSL.html in the default directory and CMake will find it.

I just tried it out of curiosity and it found 0.9.8ze which I had also installed.

Whereever CMake finds OpenSSL, in the end it should install all needed files in the CMAKE_INSTALL_PREFIX directory. See the README.cmake of Apache.
Back to top
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Fri 27 Feb '15 18:25    Post subject: Reply with quote

Jan-E wrote:
Install https://slproweb.com/download/Win64OpenSSL-1_0_1L.exe from https://slproweb.com/products/Win32OpenSSL.html in the default directory and CMake will find it.

I just tried it out of curiosity and it found 0.9.8ze which I had also installed.

Whereever CMake finds OpenSSL, in the end it should install all needed files in the CMAKE_INSTALL_PREFIX directory. See the README.cmake of Apache.


i can't use any other openssl. I have patches against openssl as well. I NEED my particular openssl build.

Also, I did read the README.cmake file. It explicitly states that it does NOT do what you are saying it does:
Quote:

Running the server and support programs
---------------------------------------

This build system does not copy binaries such as dlls from other projects
into the httpd install location. Without taking some precautions, httpd
and support programs can fail to start or modules can fail to load because
a support library can't be found in PATH or in the directory of the httpd
binary.

This can be resolved in several different ways:

* Install httpd and the various support libraries to a common install
prefix so that support libraries and httpd programs are installed in
the same bin directory and are found without setting PATH.


This particular bullet is what I'm trying to do.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 27 Feb '15 19:41    Post subject: Reply with quote

If I were you I would skip CMake, because it apparently is causing a lot of trouble.
Did you try to use use Gregg's *.mak files and run

nmake -f Makefile.win PORT=80 INSTDIR="C:\Apache24" installr

Then you will be a lot closer to the solution than with CMake, I guess.

I took another road. I made a X86 VC11 project first and then added the x64 configuration to the Apache/httpd project. At first this seems to fail, because the builds are made in .\x64\Release and the like. I did a global find and removed every x64\ and \x64 in all *.vcxproj files.

The VC11 project itself fails because of missing lua.h and the like, but I call it from the command line:

Code:

set VisualStudioVersion=11.0
wdexpress srclib/apr/apr.vcxproj /Build "Release|x64"
wdexpress srclib/apr-iconv/apriconv.vcxproj /Build "Release|x64"
wdexpress srclib/apr/libapr.vcxproj /Build "Release|x64"
wdexpress Apache_VC11.sln /Build "Release|x64"
nmake -f Makefile.win PORT=80 INSTDIR="\Apache24" installr


As you can see by the 'wdexpress', I am using VC11 Express for Desktop. With VC11 Pro, that must be devenv AFAIK.
The four lines with wdexpress do the 'make', the line with nmake is the 'make install'.

My build files are here:
https://phpdev.toolsforresearch.com/build24.zip

Be sure you do not have a Apache.sln in the source directory, because makefile.win should not find it.
Back to top
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Fri 27 Feb '15 20:28    Post subject: Reply with quote

Hehe. Funny you should ask that.
See:
http://www.apachelounge.com/viewtopic.php?t=6368

My goal here is to be able to create a reproducible build without the need to depend on "random" resources.

With 32-bit httpd I'm able to reproduce a build using nothing more than the source bundles from the various groups (httpd httpd-deps openssl pcre zlib).

I'm trying to avoid having to rely on on artifacts generated from someone else. At the very least, I'd like to learn how to generate those artifacts.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 27 Feb '15 20:40    Post subject: Reply with quote

wangmaster wrote:
Hehe. Funny you should ask that.
I'm trying to avoid having to rely on on artifacts generated from someone else. At the very least, I'd like to learn how to generate those artifacts.

Then you should make a build tree with srclib/apr/apr-iconv/apr-util/zlib/pcre/openssl, open Apache.dsw with VC11 and struggle along. If you can make that work with x86 (Win32), you are close. Good luck!
Back to top
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Sat 28 Feb '15 0:46    Post subject: Reply with quote

Thanks to Jeff Trawick on users@httpd.apache.org I have a successful build.

The issue with apr-util not finding openssl was that I was trying to use openssl 1.0.2 and it just simply doesn't work.

Dropped back to openssl 1.0.1l and so far so good.
Back to top
wangmaster



Joined: 25 Feb 2015
Posts: 12

PostPosted: Tue 03 Mar '15 18:28    Post subject: Reply with quote

My pet peeve is coming across forum postings and not seeing any detail in the final resolution to them Smile So I'm not going to be that guy.

Here's how I built everything:
openssl:
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:
https://github.com/madler/zlib/pull/72

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 Smile

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.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Thu 19 Mar '15 22:10    Post subject: Reply with quote

wangmaster wrote:
Thanks to Jeff Trawick on users@httpd.apache.org I have a successful build.

The issue with apr-util not finding openssl was that I was trying to use openssl 1.0.2 and it just simply doesn't work.

Dropped back to openssl 1.0.1l and so far so good.

Using OpenSSL 1.0.2 is like living on the edge:
http://openssl.org/news/secadv_20150319.txt
You'd better stay with 1.0.1 for a while.
Back to top
idblew



Joined: 14 Nov 2014
Posts: 10
Location: Melbourne, Australia

PostPosted: Sun 29 Mar '15 3:22    Post subject: Reply with quote

I've got this working with OpenSSL 1.0.2a and have written a HOW-TO which can be found at http://www.apachelounge.com/viewtopic.php?t=6462
Back to top


Reply to topic   Topic: Building Apache 2.4.12 Windows x64 with cmake View previous topic :: View next topic
Post new topic   Forum Index -> Building & Member Downloads