Recompiling with ServBay
ServBay provides macOS and Windows users with a powerful and comprehensive local web development environment, packed with a wide variety of packages and tools. While ServBay ships with many pre-installed package versions, developers may have unique needs for recompilation, such as:
- Enabling specific build options for a package.
- Adding modules or extensions ServBay doesn’t include by default (like new PHP or PostgreSQL modules).
- Compiling with different libraries than those supplied in ServBay.
- Customizing packages provided by ServBay.
ServBay gives you everything needed for these custom compilation tasks.
To recompile successfully, users should have basic knowledge of the build process for their operating system:
- macOS/Linux: Unix/Linux toolchains such as
configure
,make
,make install
. - Windows: Visual Studio build system, MSBuild, cmake, and related tools.
Prerequisites
Before you start recompiling, ensure you’ve got the following set up:
Install the ServBay Development Library: This is the key dependency for recompilation. It includes all required libraries, header files, and other development resources for compiling within ServBay. Find and install it from the Packages panel in the ServBay app.
Install Developer Toolkits:
macOS
Install Xcode Command Line Tools: These are Apple's essential developer tools, including the Clang compiler and linker. Open Terminal and run:
bashxcode-select --install
1If you’ve already installed them, you’ll be notified.
Install Additional Build Tools: You’ll often need
autoconf
,automake
,libtool
, etc., for compiling most open-source software. Install them via Homebrew package manager:bashbrew install autoconf automake libtool cmake
1If Homebrew isn’t installed, visit the official Homebrew site for instructions.
Windows
Install Visual Studio Build Tools or Visual Studio Community: Windows requires Microsoft's C++ compiler and build system. Choose one of the following:
Option 1: Visual Studio Build Tools (recommended, smaller installation)
- Download and install Visual Studio Build Tools
- During installation, select the "C++ build tools" workload.
- Ensure these components are included:
- MSVC v143 - VS 2022 C++ x64/x86 Build Tools
- Windows 11 SDK (latest version)
- CMake tools
Option 2: Visual Studio Community
- Download and install Visual Studio Community
- During setup, select the "Desktop development with C++" workload.
- Include CMake tools and Windows SDK.
Install Extra Tools: For some open-source projects, you might also need:
- Git for Windows: For source code downloads
- MSYS2 or vcpkg: For C/C++ library dependency management
- Python: Required by certain build scripts
powershell# Install extra tools using Chocolatey (optional) choco install git cmake python msys2
1
2
Setting Up the Build Environment
Once the ServBay Development Library and required tools are installed, you’ll need to initialize your build environment. This means setting a set of environment variables that tell your compiler and build system where ServBay's libraries, headers, and binaries are, so dependencies can be located and linked correctly.
The details differ depending on your OS and CPU architecture.
macOS
ServBay supports both Intel (x86_64) and Apple Silicon (Arm64) chips. Choose the correct environment initialization script for your ServBay Runtime architecture.
Windows
The Windows version supports x64 architecture, installed at C:\ServBay
.
Checking ServBay Runtime CPU Architecture
macOS
Check the architecture of any binary in ServBay's bin
directory. For example, with bison
:
bash
# Run this command in Terminal to check
$ file /Applications/ServBay/bin/bison
/Applications/ServBay/bin/bison: Mach-O 64-bit executable arm64
1
2
3
2
3
bash
# Run this command in Terminal to check
$ file /Applications/ServBay/bin/bison
/Applications/ServBay/bin/bison: Mach-O 64-bit executable x86_64
1
2
3
2
3
Windows
Windows ServBay currently supports x64. Check an executable with PowerShell:
powershell
# In PowerShell, run:
PS> Get-Command "C:\ServBay\bin\bison.exe" | Select-Object -ExpandProperty FileVersionInfo | Select-Object ProductName, FileDescription
1
2
2
Or, check the file properties directly.
After confirming the architecture, use the corresponding initialization script.
Initializing Build Environment Variables
Choose the script matching your OS and architecture:
macOS
Open a new Terminal window and paste in the script for your CPU architecture. These commands set paths and flags for ServBay’s build environment.
bash
# Number of CPU cores for parallel builds
CPU_NUMBER=$(sysctl -n hw.ncpu)
# ServBay base install path
SERVBAY_BASE_FULL_PATH="/Applications/ServBay"
# Package directory name
SERVBAY_PACKAGE_DIR_NAME="package"
# Full package path
SERVBAY_PACKAGE_FULL_PATH="${SERVBAY_BASE_FULL_PATH}/${SERVBAY_PACKAGE_DIR_NAME}"
# ServBay binary paths
SERVBAY_BIN_PATH="${SERVBAY_PACKAGE_FULL_PATH}/bin"
SERVBAY_SBIN_PATH="${SERVBAY_PACKAGE_FULL_PATH}/sbin"
# ServBay config path
SERVBAY_ETC_PATH="${SERVBAY_PACKAGE_FULL_PATH}/etc"
# Variable data path
SERVBAY_VAR_PATH="${SERVBAY_PACKAGE_FULL_PATH}/var"
# Development Library install path
SERVBAY_COMMON_PATH="${SERVBAY_PACKAGE_FULL_PATH}/common"
# Header and library paths
SERVBAY_COMMON_INCLUDE_PATH="${SERVBAY_COMMON_PATH}/include"
SERVBAY_COMMON_LIB_PATH="${SERVBAY_COMMON_PATH}/lib"
SERVBAY_COMMON_LIBEXEC_PATH="${SERVBAY_COMMON_PATH}/libexec"
SERVBAY_COMMON_SHARE_PATH="${SERVBAY_COMMON_PATH}/share"
SERVBAY_COMMON_MAN_PATH="${SERVBAY_COMMON_PATH}/man"
SERVBAY_COMMON_DOC_PATH="${SERVBAY_COMMON_PATH}/doc"
# Current build directories
SERVBAY_BUILD_DIR=$(pwd)
SERVBAY_BUILD_SRC_DIR=${SERVBAY_BUILD_DIR}/src
# OpenSSL info
OPENSSL_SELECTED_VERSION="3.2"
OPENSSL_VERSION="3.2.1"
# Minimum target OS version
BUILD_OS_MIN_VERSION="12.00" # macOS Monterey or later
# Build architecture flags
BUILD_CPU_ARCH="-arch arm64"
BUILD_CPU_ARCH_CMAKE="arm64"
BUILD_MACOS_TARGET="" # Arm64 usually doesn't need -target
# Compiler flags: optimization, OS version, architecture
export CFLAGS="-Qunused-arguments -O3 -mmacosx-version-min=${BUILD_OS_MIN_VERSION} ${BUILD_CPU_ARCH} ${BUILD_MACOS_TARGET}"
# Linker flags: rpath, library paths, OS version, architecture
export LDFLAGS="-Wl,-rpath -Wl,${SERVBAY_COMMON_LIB_PATH} -L${SERVBAY_COMMON_LIB_PATH} -L${SERVBAY_PACKAGE_FULL_PATH} -mmacosx-version-min=${BUILD_OS_MIN_VERSION} ${BUILD_CPU_ARCH} ${BUILD_MACOS_TARGET}"
# Preprocessor and CXX flags: include paths
export CPPFLAGS="-I${SERVBAY_COMMON_INCLUDE_PATH}"
export CXXFLAGS="-Qunused-arguments -O3 -mmacosx-version-min=${BUILD_OS_MIN_VERSION} ${BUILD_CPU_ARCH} ${BUILD_MACOS_TARGET}"
# Prioritize ServBay's bin/sbin
export PATH="${SERVBAY_BIN_PATH}:${SERVBAY_SBIN_PATH}:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
# pkg-config paths
export PKG_CONFIG_PATH="${SERVBAY_COMMON_LIB_PATH}/pkgconfig"
export PKG_CONFIG="${SERVBAY_BIN_PATH}/pkg-config"
export PKG_CONFIG_LIBDIR="${SERVBAY_COMMON_LIB_PATH}/pkgconfig"
# Add system/Homebrew paths as fallback
export PATH=$PATH:"/usr/local/bin:/usr/local/sbin"
export PATH=$PATH:"/opt/homebrew/bin/" # Default Homebrew
# Add OpenSSL library and headers
export LDFLAGS="-L${SERVBAY_COMMON_PATH}/openssl/${OPENSSL_SELECTED_VERSION}/lib ${LDFLAGS}"
export CPPFLAGS="-I${SERVBAY_COMMON_PATH}/openssl/${OPENSSL_SELECTED_VERSION}/include ${CPPFLAGS}"
# OpenSSL pkgconfig
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${SERVBAY_COMMON_PATH}/openssl/${OPENSSL_SELECTED_VERSION}/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="${PKG_CONFIG_LIBDIR}:${SERVBAY_COMMON_PATH}/openssl/${OPENSSL_SELECTED_VERSION}/lib/pkgconfig"
# You're ready to compile in this terminal!
echo "ServBay Arm64 build environment set."
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
bash
# Number of CPU cores for parallel builds
CPU_NUMBER=$(sysctl -n hw.ncpu)
# ServBay base install path
SERVBAY_BASE_FULL_PATH="/Applications/ServBay"
# Package directory name
SERVBAY_PACKAGE_DIR_NAME="package"
# Full package path
SERVBAY_PACKAGE_FULL_PATH="${SERVBAY_BASE_FULL_PATH}/${SERVBAY_PACKAGE_DIR_NAME}"
# ServBay binary paths
SERVBAY_BIN_PATH="${SERVBAY_PACKAGE_FULL_PATH}/bin"
SERVBAY_SBIN_PATH="${SERVBAY_PACKAGE_FULL_PATH}/sbin"
# ServBay config path
SERVBAY_ETC_PATH="${SERVBAY_PACKAGE_FULL_PATH}/etc"
# Variable data path
SERVBAY_VAR_PATH="${SERVBAY_PACKAGE_FULL_PATH}/var"
# Development Library install path
SERVBAY_COMMON_PATH="${SERVBAY_PACKAGE_FULL_PATH}/common"
# Header and library paths
SERVBAY_COMMON_INCLUDE_PATH="${SERVBAY_COMMON_PATH}/include"
SERVBAY_COMMON_LIB_PATH="${SERVBAY_COMMON_PATH}/lib"
SERVBAY_COMMON_LIBEXEC_PATH="${SERVBAY_COMMON_PATH}/libexec"
SERVBAY_COMMON_SHARE_PATH="${SERVBAY_COMMON_PATH}/share"
SERVBAY_COMMON_MAN_PATH="${SERVBAY_COMMON_PATH}/man"
SERVBAY_COMMON_DOC_PATH="${SERVBAY_COMMON_PATH}/doc"
# Current build directories
SERVBAY_BUILD_DIR=$(pwd)
SERVBAY_BUILD_SRC_DIR=${SERVBAY_BUILD_DIR}/src
# OpenSSL info
OPENSSL_SELECTED_VERSION="1.1.1u"
OPENSSL_VERSION="1.1.1u"
# Minimum target OS version
BUILD_OS_MIN_VERSION="12.00" # macOS Monterey or later
# Build architecture flags
BUILD_CPU_ARCH="-arch x86_64"
BUILD_CPU_ARCH_CMAKE="x86_64"
BUILD_MACOS_TARGET="-target x86_64-apple-macos${BUILD_OS_MIN_VERSION}"
# Compiler flags: optimization, OS version, architecture, target
export CFLAGS="-Qunused-arguments -O3 -mmacosx-version-min=${BUILD_OS_MIN_VERSION} ${BUILD_CPU_ARCH} ${BUILD_MACOS_TARGET}"
# Linker flags: rpath, library paths, OS version, architecture, target
export LDFLAGS="-Wl,-rpath -Wl,${SERVBAY_COMMON_LIB_PATH} -L${SERVBAY_COMMON_LIB_PATH} -L${SERVBAY_PACKAGE_FULL_PATH} -mmacosx-version-min=${BUILD_OS_MIN_VERSION} ${BUILD_CPU_ARCH} ${BUILD_MACOS_TARGET}"
# Preprocessor and CXX flags: include paths
export CPPFLAGS="-I${SERVBAY_COMMON_INCLUDE_PATH}"
export CXXFLAGS="-Qunused-arguments -O3 -mmacosx-version-min=${BUILD_OS_MIN_VERSION} ${BUILD_CPU_ARCH} ${BUILD_MACOS_TARGET}"
# Prioritize ServBay's bin/sbin
export PATH="${SERVBAY_BIN_PATH}:${SERVBAY_SBIN_PATH}:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
# pkg-config paths
export PKG_CONFIG_PATH="${SERVBAY_COMMON_LIB_PATH}/pkgconfig"
export PKG_CONFIG="${SERVBAY_BIN_PATH}/pkg-config"
export PKG_CONFIG_LIBDIR="${SERVBAY_COMMON_LIB_PATH}/pkgconfig"
# Add system/Homebrew paths as fallback
export PATH=$PATH:"/usr/local/bin:/usr/local/sbin"
export PATH=$PATH:"/opt/homebrew/bin/" # Default Homebrew
# Add OpenSSL library and headers
export LDFLAGS="-L${SERVBAY_COMMON_PATH}/openssl/${OPENSSL_SELECTED_VERSION}/lib ${LDFLAGS}"
export CPPFLAGS="-I${SERVBAY_COMMON_PATH}/openssl/${OPENSSL_SELECTED_VERSION}/include ${CPPFLAGS}"
# OpenSSL pkgconfig
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${SERVBAY_COMMON_PATH}/openssl/${OPENSSL_SELECTED_VERSION}/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="${PKG_CONFIG_LIBDIR}:${SERVBAY_COMMON_PATH}/openssl/${OPENSSL_SELECTED_VERSION}/lib/pkgconfig"
# You're ready to compile in this terminal!
echo "ServBay x86_64 build environment set."
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Windows
On Windows, set environment variables in PowerShell or Developer Command Prompt. This script suits Windows x64:
powershell
# Number of CPU cores for parallel builds
$CPU_NUMBER = (Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors
# ServBay base install path
$SERVBAY_BASE_FULL_PATH = "C:\ServBay"
# Package directory name
$SERVBAY_PACKAGE_DIR_NAME = "package"
# Full package path
$SERVBAY_PACKAGE_FULL_PATH = "${SERVBAY_BASE_FULL_PATH}\${SERVBAY_PACKAGE_DIR_NAME}"
# ServBay binary paths
$SERVBAY_BIN_PATH = "${SERVBAY_PACKAGE_FULL_PATH}\bin"
$SERVBAY_SBIN_PATH = "${SERVBAY_PACKAGE_FULL_PATH}\sbin"
# Config and variable data paths
$SERVBAY_ETC_PATH = "${SERVBAY_PACKAGE_FULL_PATH}\etc"
$SERVBAY_VAR_PATH = "${SERVBAY_PACKAGE_FULL_PATH}\var"
# Development Library install path
$SERVBAY_COMMON_PATH = "${SERVBAY_PACKAGE_FULL_PATH}\common"
$SERVBAY_COMMON_INCLUDE_PATH = "${SERVBAY_COMMON_PATH}\include"
$SERVBAY_COMMON_LIB_PATH = "${SERVBAY_COMMON_PATH}\lib"
$SERVBAY_COMMON_LIBEXEC_PATH = "${SERVBAY_COMMON_PATH}\libexec"
$SERVBAY_COMMON_SHARE_PATH = "${SERVBAY_COMMON_PATH}\share"
$SERVBAY_COMMON_DOC_PATH = "${SERVBAY_COMMON_PATH}\doc"
# Build directories
$SERVBAY_BUILD_DIR = Get-Location
$SERVBAY_BUILD_SRC_DIR = "${SERVBAY_BUILD_DIR}\src"
# OpenSSL info
$OPENSSL_SELECTED_VERSION = "3.2"
$OPENSSL_VERSION = "3.2.1"
# Windows build config
$BUILD_PLATFORM = "x64"
$BUILD_CONFIG = "Release"
# Set environment variables
$env:SERVBAY_BASE_FULL_PATH = $SERVBAY_BASE_FULL_PATH
$env:SERVBAY_COMMON_PATH = $SERVBAY_COMMON_PATH
$env:SERVBAY_COMMON_INCLUDE_PATH = $SERVBAY_COMMON_INCLUDE_PATH
$env:SERVBAY_COMMON_LIB_PATH = $SERVBAY_COMMON_LIB_PATH
# Update PATH to prioritize ServBay's bin/sbin
$env:PATH = "${SERVBAY_BIN_PATH};${SERVBAY_SBIN_PATH};$env:PATH"
# Compiler variables
$env:INCLUDE = "${SERVBAY_COMMON_INCLUDE_PATH};$env:INCLUDE"
$env:LIB = "${SERVBAY_COMMON_LIB_PATH};$env:LIB"
$env:LIBPATH = "${SERVBAY_COMMON_LIB_PATH};$env:LIBPATH"
# pkg-config paths (if available)
$env:PKG_CONFIG_PATH = "${SERVBAY_COMMON_LIB_PATH}\pkgconfig"
# OpenSSL header and library paths
$env:INCLUDE = "${SERVBAY_COMMON_PATH}\openssl\${OPENSSL_SELECTED_VERSION}\include;$env:INCLUDE"
$env:LIB = "${SERVBAY_COMMON_PATH}\openssl\${OPENSSL_SELECTED_VERSION}\lib;$env:LIB"
# cmake variables
$env:CMAKE_PREFIX_PATH = $SERVBAY_COMMON_PATH
$env:CMAKE_INSTALL_PREFIX = $SERVBAY_COMMON_PATH
# Environment setup complete
Write-Host "ServBay Windows x64 build environment set."
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
If you're using Developer Command Prompt, you can also use this batch script:
batch
@echo off
REM Set up ServBay Windows build environment
REM ServBay base path
set SERVBAY_BASE_FULL_PATH=C:\ServBay
set SERVBAY_PACKAGE_FULL_PATH=%SERVBAY_BASE_FULL_PATH%\package
REM ServBay paths
set SERVBAY_BIN_PATH=%SERVBAY_PACKAGE_FULL_PATH%\bin
set SERVBAY_COMMON_PATH=%SERVBAY_PACKAGE_FULL_PATH%\common
set SERVBAY_COMMON_INCLUDE_PATH=%SERVBAY_COMMON_PATH%\include
set SERVBAY_COMMON_LIB_PATH=%SERVBAY_COMMON_PATH%\lib
REM OpenSSL version
set OPENSSL_SELECTED_VERSION=3.2
REM Set environment variables
set PATH=%SERVBAY_BIN_PATH%;%PATH%
set INCLUDE=%SERVBAY_COMMON_INCLUDE_PATH%;%SERVBAY_COMMON_PATH%\openssl\%OPENSSL_SELECTED_VERSION%\include;%INCLUDE%
set LIB=%SERVBAY_COMMON_LIB_PATH%;%SERVBAY_COMMON_PATH%\openssl\%OPENSSL_SELECTED_VERSION%\lib;%LIB%
set CMAKE_PREFIX_PATH=%SERVBAY_COMMON_PATH%
echo ServBay Windows build environment set.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Important: These environment variables only exist in your current terminal session. If you close the window or open a new one, rerun the script to reset the build environment.
Compilation Examples
With the build environment set up, you're ready to download and compile source code. Below are common cross-platform build examples.
Compiling ImageMagick
ImageMagick is a powerful image processing library and a dependency for the PHP imagick
extension. ServBay ships it by default, so you usually won’t need to compile it yourself. This example simply demonstrates how to compile using the ServBay environment.
macOS / Linux
Download and extract ImageMagick:
bash# Replace with the latest version as needed wget https://imagemagick.org/archive/releases/ImageMagick-7.1.1-33.tar.gz tar zxvf ImageMagick-7.1.1-33.tar.gz cd ImageMagick-7.1.1-33
1
2
3
4Run the
./configure
script: Use the previously set environment variables. The--prefix
,--libdir
,--includedir
, and similar flags should point to ServBay Development Library's common directory${SERVBAY_COMMON_PATH}
and subfolders, so other ServBay packages (like PHP'simagick
) can locate your built libraries and headers.bash./configure \ --prefix=${SERVBAY_COMMON_PATH} \ --libdir=${SERVBAY_COMMON_LIB_PATH} \ --includedir=${SERVBAY_COMMON_INCLUDE_PATH} \ --oldincludedir=${SERVBAY_COMMON_INCLUDE_PATH} \ --bindir=${SERVBAY_BIN_PATH} \ --sbindir=${SERVBAY_SBIN_PATH} \ --sysconfdir=${SERVBAY_ETC_PATH} \ --datarootdir=${SERVBAY_COMMON_SHARE_PATH} \ --enable-osx-universal-binary=no \ --disable-silent-rules \ --disable-opencl \ --enable-shared \ --enable-static \ --with-freetype=yes \ --with-gvc=no \ --with-modules \ --with-webp=yes \ --with-heic=no \ --without-gslib \ --with-fpx=no \ --without-openexexr \ --with-raw=yes \ --without-lqr \ --without-djvu \ --without-fftw \ --without-pango \ --without-wmf \ --without-x \ --with-gs-font-dir=${SERVBAY_COMMON_SHARE_PATH}/ghostscript/10.02.1/Resource/Font
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30Run
make
andmake install
:make
compiles and builds the binaries and libraries; the-j ${CPU_NUMBER}
flag boosts speed using all CPU cores.make install
puts built files into the ServBay Development Library as specified.bashmake -j ${CPU_NUMBER} make install
1
2
Windows
On Windows, ImageMagick is best compiled with Visual Studio or CMake (recommended):
Download ImageMagick source:
powershell# Use curl or browser download curl -O https://imagemagick.org/archive/releases/ImageMagick-7.1.1-33.tar.gz # Extract (needs 7zip or similar tool) tar -xzf ImageMagick-7.1.1-33.tar.gz cd ImageMagick-7.1.1-33
1
2
3
4
5Configure with CMake (in Developer Command Prompt or PowerShell):
powershell# Create build directory mkdir builddir cd builddir # Run CMake config cmake .. ` -DCMAKE_INSTALL_PREFIX="$env:SERVBAY_COMMON_PATH" ` -DCMAKE_BUILD_TYPE=Release ` -DBUILD_SHARED_LIBS=ON ` -DMAGICKCORE_QUANTUM_DEPTH=16 ` -DMAGICKCORE_HDRI_ENABLE=OFF ` -DWITH_BZLIB=ON ` -DWITH_ZLIB=ON ` -DWITH_PNG=ON ` -DWITH_JPEG=ON ` -DWITH_TIFF=ON ` -DWITH_FREETYPE=ON ` -DWITH_WEBP=ON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18Build and install:
powershell# Build cmake --build . --config Release --parallel $CPU_NUMBER # Install cmake --install . --config Release
1
2
3
4
Compiling with cmake
Packages using cmake
have a relatively consistent build workflow across platforms. For example, compiling protobuf
(Protocol Buffers):
- Download protobuf sources and enter the directory.
macOS / Linux
Run
cmake
configuration:-S .
sets the source directory to current,-B builddir
usesbuilddir
for build files. The-DCMAKE_INSTALL_PREFIX
and other variables work like Autotools'--prefix
, telling CMake to install to the ServBay Development Library. The other-D
options tailor the protobuf build.-DCMAKE_MACOSX_RPATH=1
and-DCMAKE_INSTALL_RPATH
ensure libraries are found by ServBay.bash# Assuming you're in protobuf source directory cmake -S . -B builddir \ -DCMAKE_INSTALL_PREFIX=${SERVBAY_COMMON_PATH} \ -DCMAKE_INSTALL_LIBDIR=${SERVBAY_COMMON_LIB_PATH} \ -DCMAKE_INSTALL_INCLUDEDIR=${SERVBAY_COMMON_INCLUDE_PATH} \ -DCMAKE_INSTALL_BINDIR=${SERVBAY_BIN_PATH} \ -DCMAKE_INSTALL_SBINDIR=${SERVBAY_SBIN_PATH} \ -DCMAKE_INSTALL_SYSCONFDIR=${SERVBAY_ETC_PATH} \ -DCMAKE_INSTALL_DATAROOTDIR=${SERVBAY_COMMON_SHARE_PATH} \ -DCMAKE_MACOSX_RPATH=1 \ -DCMAKE_INSTALL_RPATH=${SERVBAY_COMMON_LIB_PATH} \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE \ -DCMAKE_PREFIX_PATH=${SERVBAY_COMMON_PATH} \ -DBUILD_SHARED_LIBS=ON \ -Dprotobuf_BUILD_LIBPROTOC=ON \ -Dprotobuf_BUILD_SHARED_LIBS=ON \ -Dprotobuf_INSTALL_EXAMPLES=OFF \ -Dprotobuf_BUILD_TESTS=OFF \ -Dprotobuf_ABSL_PROVIDER=package \ -Dprotobuf_JSONCPP_PROVIDER=module \ -DCMAKE_CXX_STANDARD=17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21Build and install:
bashcmake --build builddir -j ${CPU_NUMBER} cmake --install builddir
1
2
Windows
Configure with
cmake
(in PowerShell or Developer Command Prompt):powershell# Assuming you're in protobuf source directory cmake -S . -B builddir ` -DCMAKE_INSTALL_PREFIX="$env:SERVBAY_COMMON_PATH" ` -DCMAKE_BUILD_TYPE=Release ` -DCMAKE_PREFIX_PATH="$env:SERVBAY_COMMON_PATH" ` -DBUILD_SHARED_LIBS=ON ` -Dprotobuf_BUILD_LIBPROTOC=ON ` -Dprotobuf_BUILD_SHARED_LIBS=ON ` -Dprotobuf_INSTALL_EXAMPLES=OFF ` -Dprotobuf_BUILD_TESTS=OFF ` -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ` -DCMAKE_CXX_STANDARD=17
1
2
3
4
5
6
7
8
9
10
11
12Build and install:
powershell# Build cmake --build builddir --config Release --parallel $CPU_NUMBER # Install cmake --install builddir --config Release
1
2
3
4
Compiling PHP Modules
If you want to compile extra PHP extensions for a specific ServBay PHP version (like swoole
, redis
, mongodb
, etc.), see the dedicated guide:
Compiling PostgreSQL Modules
If you need extra modules for your ServBay PostgreSQL installation, refer to:
How to Compile PostgreSQL Modules
Summary
With the ServBay Development Library and robust environment configuration, developers can easily customize and recompile packages on both macOS and Windows. This gives you the flexibility to meet project-specific needs or use the latest library versions.
Key Points
- Cross-Platform Support: ServBay now enables building on both macOS and Windows
- Path Differences: Note install paths differ (macOS:
/Applications/ServBay
, Windows:C:\ServBay
) - Toolchains: macOS uses Xcode Command Line Tools, Windows uses Visual Studio Build Tools
- Environment Setup: Choose the right environment variable script for your platform
Notes
- Carefully read each package’s official build guide before compiling
- Adjust steps and configuration for your target platform
- Prefer using CMake on Windows for builds
- Some open-source software has platform-specific build requirements and dependencies
By following this guide, you’ll be able to successfully build packages in the ServBay environment on both platforms.