Author |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Mon 14 Jun '21 5:09 Post subject: Building with cmake, expat and apr-iconv |
|
|
Split from HOWTO: Building Apache and dependencies using CMake https://www.apachelounge.com/viewtopic.php?t=8609
CMake Warning: Manually-specified variables were not used by the project: INSTALL_MSVC_PDB when compile Jansson, Brotli, Lua and cURL!
CMake Warning: Manually-specified variables were not used by the project: STATIC_LIB_SUFFIX when compile Nghttp2!
Are you sure you don't need to add -DINSTALL_MSVC_PDB=OFF to Expat? |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 348 Location: UK
|
Posted: Mon 14 Jun '21 22:27 Post subject: |
|
|
Predictably, this CMake build process is work in progress, so I've not bothered too much about minor CMake warnings.
Each package development team uses different features in their CMakeLists.txt file, and not all of them support creating PDB files. So I nominally added INSTALL_MSVC_PDB to all CMake option sets, in case they choose to do so in the future. Looks like I missed out Expat.
With regards to the STATIC_LIB_SUFFIX option with Nghttp2, it is used in lib/CMakeLists.txt when building a static library. At some point I was playing with building a static library with the ENABLE_STATIC_LIB option, so the suffix option is a hangover. |
|
Back to top |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Mon 14 Jun '21 23:24 Post subject: |
|
|
I followed the instructions you shared above, running build_all.bat using PowerShell (x64), but I use Visual Studio 2013 and Active Perl. However, I got the Code: | EXPAT cannot be found | error after the compiler started for a while. Looks like it ran out of order so expat was ignored.
Also, can you send me the full command line to compile apr-iconv? I got dizzy trying to filter out the apr-iconv compilation commands in the build_all.bat file.
UPDATE: Probably only PCRE uses -DINSTALL_MSVC_PDB variable, other features all give warning -DINSTALL_MSVC_PDB is not used in project. |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 348 Location: UK
|
Posted: Tue 15 Jun '21 22:00 Post subject: |
|
|
As it stands, the build_all.bat script doesn't abort if it can't find a named package source; it simply carries on.
So regarding Expat, assuming you created a log file during your build, I'd guess it's missing the build details for Expat. It's currently the third package in the build list. Suggest you check the Expat version defined in your build_all.bat compared to the name of the extracted source folder. Expat is needed for apr-util, so that might be where your fatal error occurred.
As far as apr-iconv goes, there isn't one single command line to build it, and there's no support for CMake. Agree it's complicated, but the details are commented to explain what's going on. We have to use various makefiles provided (four if I recall), to create the required libraries and then the various files for the iconv folder. Predictably, it took me a long time to crack building apr-iconv outside of Visual Studio. |
|
Back to top |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Thu 17 Jun '21 19:23 Post subject: |
|
|
I have checked the feature source folder name is the same as in build_all.bat however I have not checked the log file. I have a pretty complete build, just missing apr-iconv. I'm trying to filter the command line, pretty hard to find. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7374 Location: Germany, Next to Hamburg
|
Posted: Thu 17 Jun '21 21:49 Post subject: |
|
|
tanquang wrote: | I'm trying to filter the command line, pretty hard to find. |
You could use findstr(ing)
Code: |
netstat -ano | findstr /R 0.0:80 && netstat -ano | findstr /R 0.0:443
|
I do what for finding programs that block the internet ports.
Another idea is to redirect the full output of the build script via ">> build.log" into a log file an exam that later on. |
|
Back to top |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Fri 18 Jun '21 16:00 Post subject: |
|
|
I build them on Windows, the ports are all unblocked. Quote: | I'm trying to filter the command line, pretty hard to find. | I mean here the apr-iconv compile statement. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7374 Location: Germany, Next to Hamburg
|
|
Back to top |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Tue 22 Jun '21 17:43 Post subject: |
|
|
Do you have a command line that compiles with a makefile? |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 348 Location: UK
|
Posted: Tue 22 Jun '21 20:14 Post subject: |
|
|
@tanquang - you haven't said why you're failing to build apr-iconv using the above build_all.bat.
The section for building apr-iconv contains four specific nmake commands, against various package Makefiles, viz:
Code: | nmake /f apriconv.mak CFG="apriconv - !BUILD_CFG! %BUILD_TYPE%" & call :get_status
nmake /f libapriconv.mak CFG="libapriconv - !BUILD_CFG! %BUILD_TYPE%" & call :get_status |
and the following nmake in two different directories.
Code: | nmake /f Makefile.win BUILD_MODE="!BUILD_CFG! %BUILD_TYPE%" BIND_MODE="shared" & call :get_status |
What if any errors are you getting?
Can I suggest you open your apr-iconv build problem as a separate topic, rather than adding to this topic which is primarily a How-to document. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7374 Location: Germany, Next to Hamburg
|
Posted: Tue 22 Jun '21 22:03 Post subject: |
|
|
Code: |
nmake /f Makefile.win installr INSTDIR=C:/Apache24
|
https://github.com/apache/httpd/blob/2.4.x/Makefile.win#L6
I never compiled apr-iconv directly, since the Makefile.win compiles apr-iconv if it is present in the src folder and named apr-iconv.
Unlike tangent in my compilation all folders in the src folder have no version number. |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Wed 23 Jun '21 17:27 Post subject: |
|
|
Everything has a version listed in a header file.
httpd: /include/ap_version.h
in srclib/
apr,apr-iconv,apr-util: their /include/ap(r|i|u)_version.h
brotli: /include/brotli/brotliv.h
curl: /include/curl/curlver.h
jansson: /include/janson.h
libexpat: /expat/lib/expat.h
libxml2: /include/libxml/xmlversion.h
lua: /src/lua.h
nghttp2: /lib/includes/nghttp2/nghttp2ver.h
openssl/libressl: /include/openssl/opensslv.h
pcre: /pcre.h
zlib: /zlib.h |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 348 Location: UK
|
Posted: Wed 23 Jun '21 22:35 Post subject: |
|
|
@glsmith - indeed, like other packages, apr-iconv has its version listed in a header file - .../include/ap(r|i|u)_version.h
@James - agreed, the apr-iconv Makefiles expect to build with no version numbers in the relevant folders. I simply define one for the source folder to be consistent with all the other packages.
However, my build batch file creates symlinks to folder names with no version, since this is what the Makefiles require, viz:
Code: | set APR=apr-1.7.0
set APR-ICONV=apr-iconv-1.2.2
set APR-UTIL=apr-util-1.6.1
...
rem Create non-version specific folder links to the APR, APR-ICONV and APR-UTIL sources.
rem The various makefiles assume these exist.
rem
pushd "%BUILD_BASE%\..\src"
mklink /d apr %APR% 1>nul 2>&1
mklink /d apr-iconv %APR-ICONV% 1>nul 2>&1
mklink /d apr-util %APR-UTIL% 1>nul 2>&1
popd |
|
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Thu 24 Jun '21 0:54 Post subject: |
|
|
Misunderstood I guess.
Yeah, Apache's makefile.win doesn't expect any folders to have versions numbers so you're not constantly having to modify it. |
|
Back to top |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Fri 25 Jun '21 23:28 Post subject: |
|
|
tangent wrote: | @tanquang - you haven't said why you're failing to build apr-iconv using the above build_all.bat.
The section for building apr-iconv contains four specific nmake commands, against various package Makefiles, viz:
Code: | nmake /f apriconv.mak CFG="apriconv - !BUILD_CFG! %BUILD_TYPE%" & call :get_status
nmake /f libapriconv.mak CFG="libapriconv - !BUILD_CFG! %BUILD_TYPE%" & call :get_status |
and the following nmake in two different directories.
Code: | nmake /f Makefile.win BUILD_MODE="!BUILD_CFG! %BUILD_TYPE%" BIND_MODE="shared" & call :get_status |
What if any errors are you getting?
Can I suggest you open your apr-iconv build problem as a separate topic, rather than adding to this topic which is primarily a How-to document. |
Quote: | and the following nmake in two different directories. |
Here is the command after I edited:
Code: | cd /D C:\httpd\srclib\apr-iconv
copy "\httpd\srclib\apr\bin\apr.h" ".\include"
copy "\httpd\srclib\apr\bin\apr_escape_test_char.h" ".\include"
nmake /f apriconv.mak CFG="apriconv - x64 Release"
nmake /f libapriconv.mak CFG="libapriconv - x64 Release" |
I removed 1>nul in both commands. I got an error that the command line didn't show any message after typing copy apr_escape_test_char.h, also couldn't continue compiling.
I also got the error:
Code: | NMAKE : fatal error U1073: don't know how to make '".\include\apr_escape_test_char.h"' |
Can you review the command line?
Last edited by tanquang on Sat 26 Jun '21 1:00; edited 1 time in total |
|
Back to top |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Fri 25 Jun '21 23:35 Post subject: |
|
|
James Blond wrote: | Code: |
nmake /f Makefile.win installr INSTDIR=C:/Apache24
|
https://github.com/apache/httpd/blob/2.4.x/Makefile.win#L6
I never compiled apr-iconv directly, since the Makefile.win compiles apr-iconv if it is present in the src folder and named apr-iconv.
Unlike tangent in my compilation all folders in the src folder have no version number. |
Will this command line compile apr-iconv directly? But will it compile x86 or x64 version?
I tried running this command directly and got the error:
Code: | NMAKE : fatal error U1073: don't know how to make 'installr' |
|
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7374 Location: Germany, Next to Hamburg
|
|
Back to top |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Sat 26 Jun '21 18:55 Post subject: |
|
|
Yes, I also compile all at once, not individually. This is the entire command line I use to compile.
Code: | *****************
** ZLIB Build **
*****************
cd /D D:\httpd\srclib\zlib\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
nmake
nmake install
****************
** Pcre Build **
****************
cd /D D:\httpd\srclib\pcre\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DPCRE_BUILD_TESTS=OFF -DPCRE_BUILD_PCRECPP=OFF -DPCRE_BUILD_PCREGREP=OFF -DPCRE_SUPPORT_PCREGREP_JIT=OFF -DPCRE_SUPPORT_UTF=ON -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_NEWLINE=CRLF -DINSTALL_MSVC_PDB=OFF ..
nmake
nmake install
*****************
** Expat Build **
*****************
cd /D D:\httpd\srclib\expat\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release ..
nmake
nmake install
*******************
** OpenSSL Build **
*******************
cd /D D:\httpd\srclib\openssl
perl Configure VC-WIN64A --release --prefix=\phpStudy\Apache --openssldir=\phpStudy\Apache\conf enable-camellia no-idea no-mdc2
nmake
nmake install
*******************
** libxml2 Build **
*******************
cd /D D:\httpd\srclib\libxml2\win32
nmake /f Makefile.msvc distclean 2>nul
cscript configure.js compiler=msvc prefix=\phpStudy\Apache include=\phpStudy\Apache\include lib=\phpStudy\Apache\lib iconv=no xml_debug=no python=no zlib=yes
nmake /f Makefile.msvc
nmake /f Makefile.msvc install-dist
*******************
** jansson Build **
*******************
cd /D D:\httpd\srclib\jansson\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DJANSSON_BUILD_SHARED_LIBS=ON -DJANSSON_BUILD_DOCS=OFF ..
nmake
nmake install
******************
** Brotli Build **
******************
cd /D D:\httpd\srclib\brotli\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release ..
nmake
nmake install
***************
** Lua Build **
***************
cd /D D:\httpd\srclib\lua\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release ..
nmake
nmake install
***************
** APR Build **
***************
cd /D D:\httpd\srclib\apr\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DMIN_WINDOWS_VER=0x0600 -DAPR_HAVE_IPV6=ON -DAPR_INSTALL_PRIVATE_H=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=OFF ..
nmake
nmake install
********************
** APR-Util Build **
********************
cd /D D:\httpd\srclib\apr-util\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DOPENSSL_ROOT_DIR=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DAPU_HAVE_CRYPTO=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=OFF ..
nmake
nmake install
*******************
** Nghttp2 Build **
*******************
cd /D D:\httpd\srclib\nghttp2\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DENABLE_LIB_ONLY=ON ..
nmake
nmake install
****************
** cURL Build **
****************
cd /D D:\httpd\srclib\curl\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DCMAKE_USE_OPENSSL=ON -DCMAKE_USE_SCHANNEL=ON -DCURL_WINDOWS_SSPI=ON -DCURL_BROTLI=ON -DUSE_NGHTTP2=ON -DHAVE_LDAP_SSL=ON -DENABLE_UNICODE=ON -DCURL_STATIC_CRT=OFF -DBUILD_SHARED_LIBS=ON ..
nmake
nmake install
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DCMAKE_USE_OPENSSL=ON -DCMAKE_USE_SCHANNEL=ON -DCURL_WINDOWS_SSPI=ON -DCURL_BROTLI=ON -DUSE_NGHTTP2=ON -DHAVE_LDAP_SSL=ON -DENABLE_UNICODE=ON -DCURL_STATIC_CRT=OFF -DBUILD_SHARED_LIBS=OFF ..
nmake
nmake install
******************
** Apache Build **
******************
cd /D D:\httpd\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF ..
nmake
nmake install
*********************
** mod_fcgid Build **
*********************
cd /D D:\httpd\srclib\mod_fcgid\modules\fcgid\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DINSTALL_PDB=OFF ..
nmake
nmake install |
That's my entire compiled command line. However, it is missing apr-iconv. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7374 Location: Germany, Next to Hamburg
|
Posted: Sat 26 Jun '21 21:46 Post subject: |
|
|
You don't have to!
With the IDE is like
Quote: |
command line
cd C:\build\2.4.x
srclib\apr\build\lineends.pl
srclib\apr\build\cvtdsp.pl -2005
cd srclib\zlib
nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF -I." OBJA="inffas32.obj match686.obj"
MT -manifest zlib1.dll.manifest -outputresource:zlib1.dll;2
cd ..\..\srclib\openssl
perl Configure VC-WIN32 --prefix=/Apache24 --openssldir=/Apache24/conf disable-idea
ms\do_nasm
nmake /f ms\ntdll.mak
IDE part
Open Apache.dsw with VS8/VS9 and answer "Yes to All" to the "convert projects" question
Select relase win32
Now build InstallBin |
Code: |
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF ..
nmake
nmake install
|
Your code should do the magic. Except you have to compile zlib and OpenSSL before it, and mod_fcgid after it. |
|
Back to top |
|
tanquang
Joined: 21 Mar 2020 Posts: 58 Location: Vietnam
|
Posted: Sun 27 Jun '21 17:39 Post subject: |
|
|
I compiled in the same order as in the code above, compiles normally but with slight modifications before compiling and just missing apr-iconv. |
|
Back to top |
|