This page describes the process for building the Tomcat Native for Windows. Version 2.x onwards makes OpenSSL available to the NIO and NIO2 connectors. Version 1.3.x also provides the native part of the APR/native connector.
Prerequisites
- Currently supported Windows OS (release builds use a Windows 2022 VM running on VMware)
- Currently support JDK installed (release builds use Temurin 21.0.7)
- git (if you wish to build from source)
- Perl - see OpenSSL build instructions for Windows (release builds use Strawberry Perl 5.40.2001)
- NASM - see OpenSSL build instructions for Windows (release builds use 2.16.01 included in Strawberry Perl 5.40.2001)
- Microsoft Visual C compiler (release builds use Visual Studio 2022 17.1.4.1)
Building
While tcnative itself needs to be built last, we unpack it first because it provides the structure for the build as well as the nmake file for APR. Obtain the tcnative source from one of:
- the win32-src.zip source bundle for the version you wish to build;
- https://github.com/apache/tomcat-native
E.g.: To build the latest 2.0.x development build from main
c: cd \ git clone https://github.com/apache/tomcat-native tomcat-native-2.0.x cd tomcat-native-2.0.x\native\srclib\apr
Unpack APR 1.7.6 source distribution in this directory (C:\tomcat-native-2.0.x\native\srclib\apr).
Note: If you build the 1.3.x branch you will need to apply some patches. The patches should apply but depending on exactly which revision you are working with you may need to skip parts of the patch and/or apply an offset.
git apply apr-enable-ipv6.patch
git apply win-ipv6.patch
Then build:
"c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
nmake -f NMAKEmakefile CPU=X86 APR_DECLARE_STATIC=1 "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" nmake -f NMAKEmakefile CPU=X64 APR_DECLARE_STATIC=1 cd ..\openssl
OpenSSL 3.0.x and later
Unpack the OpenSSL 3.5.x source distribution in this directory (C:\tomcat-native-2.0.x\native\srclib\openssl).
"c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
perl Configure no-shared VC-WIN32
nmake
mkdir out32-x86
copy libssl.lib out32-x86\
copy libcrypto.lib out32-x86\
copy ossl_static.pdb out32-x86\
copy apps\openssl.exe out32-x86\
nmake clean
"c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
perl Configure no-shared VC-WIN64A
nmake
mkdir out32-x64
copy libssl.lib out32-x64\
copy libcrypto.lib out32-x64\
copy ossl_static.pdb out32-x64\
copy apps\openssl.exe out32-x64\
Tomcat Native
Keeping the various libraries in versioned directories saves having to rebuild them next time if the version remains unchanged.
cd .. set OPENSSL_VER=3.5.0
set APR_VER=1.7.6
mkdir \deps-x86\apr-%APR_VER%\include mkdir \deps-x86\apr-%APR_VER%\lib mkdir \deps-x86\openssl-%OPENSSL_VER%\include mkdir \deps-x86\openssl-%OPENSSL_VER%\lib xcopy /E \deps-x86\apr-%APR_VER% \deps-x64\apr-%APR_VER%\
xcopy /E \deps-x86\openssl-%OPENSSL_VER% \deps-x64\openssl-%OPENSSL_VER%\
xcopy /E apr\include \deps-x86\apr-%APR_VER%\include\ xcopy /E apr\include \deps-x64\apr-%APR_VER%\include\ copy apr\WIN7_X86_LIB_RELEASE\apr-1.lib \deps-x86\apr-%APR_VER%\lib copy apr\WIN7_X64_LIB_RELEASE\apr-1.lib \deps-x64\apr-%APR_VER%\lib
xcopy /E openssl\include\openssl \deps-x86\openssl-%OPENSSL_VER%\include\openssl\ xcopy /E openssl\include\openssl \deps-x64\openssl-%OPENSSL_VER%\include\openssl\
copy openssl\out32-x86\*.lib \deps-x86\openssl-%OPENSSL_VER%\lib\
copy openssl\out32-x64\*.lib \deps-x64\openssl-%OPENSSL_VER%\lib\
copy openssl\out32-x86\*.pdb \deps-x86\openssl-%OPENSSL_VER%\lib\
copy openssl\out32-x64\*.pdb \deps-x64\openssl-%OPENSSL_VER%\lib\
copy openssl\out32-x86\openssl.exe \deps-x86\openssl-%OPENSSL_VER%\
copy openssl\out32-x64\openssl.exe \deps-x64\openssl-%OPENSSL_VER%\
cd ..
set JAVA_HOME=C:\java\21.0.7-tem
"c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
nmake -f NMAKEMakefile WITH_APR=C:\deps-x86\apr-%APR_VER% WITH_OPENSSL=C:\deps-x86\openssl-%OPENSSL_VER% CPU=X86 APR_DECLARE_STATIC=1 STATIC_CRT=Hybrid OPENSSL_NEW_LIBS=1 ENABLE_OCSP=1
move WIN7_X86_DLL_RELEASE WIN7_X86_OCSP_DLL_RELEASE
nmake -f NMAKEMakefile WITH_APR=C:\deps-x86\apr-%APR_VER% WITH_OPENSSL=C:\deps-x86\openssl-%OPENSSL_VER% CPU=X86 APR_DECLARE_STATIC=1 STATIC_CRT=Hybrid OPENSSL_NEW_LIBS=1
"c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
nmake -f NMAKEMakefile WITH_APR=C:\deps-x64\apr-%APR_VER% WITH_OPENSSL=C:\deps-x64\openssl-%OPENSSL_VER% CPU=X64 APR_DECLARE_STATIC=1 STATIC_CRT=Hybrid OPENSSL_NEW_LIBS=1 ENABLE_OCSP=1 move WIN7_X64_DLL_RELEASE WIN7_X64_OCSP_DLL_RELEASE nmake -f NMAKEMakefile WITH_APR=C:\deps-x64\apr-%APR_VER% WITH_OPENSSL=C:\deps-x64\openssl-%OPENSSL_VER% CPU=X64 APR_DECLARE_STATIC=1 STATIC_CRT=Hybrid OPENSSL_NEW_LIBS=1
Tomcat Native Connector DLLs may then be found in C:\tomcat-native-2.0.x\native\WIN7_*_[OCSP_]DLL_RELEASE
Construct the binary distributions
set VER=2.0.9
mkdir tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin
copy LICENSE.bin.win tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\LICENSE
copy NOTICE.bin.win tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\NOTICE
copy ..\README.txt tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\
copy srclib\VERSIONS tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\
mkdir tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\bin mkdir tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\bin\x64 copy C:\deps-x86\openssl-%OPENSSL_VER%\openssl.exe tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\bin xcopy /E tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin tomcat-native-%VER%-openssl-%OPENSSL_VER%-ocsp-win32-bin\ copy WIN7_X86_DLL_RELEASE\tcnative-2.dll tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\bin copy WIN7_X86_OCSP_DLL_RELEASE\tcnative-2.dll tomcat-native-%VER%-openssl-%OPENSSL_VER%-ocsp-win32-bin\bin copy WIN7_X86_DLL_RELEASE\tcnative-2.pdb tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\bin copy WIN7_X86_OCSP_DLL_RELEASE\tcnative-2.pdb tomcat-native-%VER%-openssl-%OPENSSL_VER%-ocsp-win32-bin\bin copy WIN7_X64_DLL_RELEASE\tcnative-2.dll tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\bin\x64 copy WIN7_X64_OCSP_DLL_RELEASE\tcnative-2.dll tomcat-native-%VER%-openssl-%OPENSSL_VER%-ocsp-win32-bin\bin\x64 copy WIN7_X64_DLL_RELEASE\tcnative-2.pdb tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin\bin\x64 copy WIN7_X64_OCSP_DLL_RELEASE\tcnative-2.pdb tomcat-native-%VER%-openssl-%OPENSSL_VER%-ocsp-win32-bin\bin\x64 set PATH=%PATH%;%JAVA_HOME%\bin cd tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin jar -cMf ..\tomcat-native-%VER%-openssl-%OPENSSL_VER%-win32-bin.zip * cd ..\tomcat-native-%VER%-openssl-%OPENSSL_VER%-ocsp-win32-bin jar -cMf ..\tomcat-native-%VER%-openssl-%OPENSSL_VER%-ocsp-win32-bin.zip *
The Windows binary distributions may then be found in C:\tomcat-native-2.0.x\native\
These need to be signed and hashed before uploading for the release vote.
Beware of typos in the name and contents of hash files for OCSP binaries ("ocsp" vs "oscp"). Such typos happened.
A correct example:
tomcat-native-2.0.5-openssl-3.0.10-ocsp-win32-bin.zip.sha512
8b82033602be8f47905804349093045b99ba9cc3f2dbf95d52be2a430bae84bbefd0b938f6b0fa9d5c54af20fcb4a00b4dd2325d7482d3cf59a2463c0935d86f *tomcat-native-2.0.5-openssl-3.0.10-ocsp-win32-bin.zip
tomcat-native-2.0.5-openssl-3.0.10-win32-bin.zip.sha512
3c599d4da5c26b3dd1ddce7add5b8126e98f0068515f8bb942cc349716ea5f88519b9a1f76b3ba9badda79955f88eaf7940a78713064ccc547a232b921c0f05b *tomcat-native-2.0.5-openssl-3.0.10-win32-bin.zip