OSXCross provides three build flavors:
stable (default):
cctools 986 and ld64 711.latest:
cctools 1030.6.3 and ld64 956.6.llvm:
ld64.lld instead of cctools and ld64.arm64, arm64e, and x86_64 targets. It does not support i386 or x86_64h.cctools lipo instead of llvm-lipo for improved compatibility.OSXCross provides a macOS cross-compilation toolchain.
OSXCross combines a host compiler, a packaged macOS SDK, Darwin-compatible binary utilities, and a compiler wrapper into a cross-compilation toolchain.
The selected build flavor determines which binary utilities and linker are used:
stable and latest flavors build
cctools-port, including tools
such as ar, lipo, and otool, together with the ld64 linker.llvm flavor uses the corresponding LLVM tools and ld64.lld. It can
optionally build cctools lipo as a compatibility replacement for llvm-lipo.During ./build.sh, the SDK is installed into the target directory, the tools
and dependencies required by the selected flavor are prepared, and the OSXCross
wrapper is compiled. The installed target-prefixed commands configure the target
triple, SDK sysroot, deployment target, and linker for macOS automatically.
Additional scripts can build optional compiler and runtime components:
./build_clang.sh)./build_apple_clang.sh)./build_gcc.sh)./build_gcc_with_arm64_support.sh)./build_compiler_rt.sh)A minimal MacPorts package manager is included. See README.MACPORTS.md.
For CMake projects, OSXCross provides architecture- and compiler-specific
launchers together with an installed toolchain file.
See README.CMAKE.md for setup, compiler selection, universal
binaries, package discovery, and complete examples.
Generate the SDK and place the resulting archive in the tarballs/ directory.
Install the OSXCross build dependencies:
See README.BUILD-DEPENDENCIES.md for required and optional dependencies,
Debian/Ubuntu installation commands, and the systems supported by tools/get_dependencies.sh.
Optionally, build a recent version of Clang and LLD:
See README.BUILD-CLANG.md for dependencies and instructions for building
upstream LLVM/Clang or Apple Clang.
By default, the OSXCross toolchain is installed in <current-directory>/target.
./build.sh prompts you to select a build flavor. Press Enter to use the default stable flavor.
Set BUILD_FLAVOR to stable, latest, or llvm to select a flavor without prompting.
When UNATTENDED=1 is set, the specified BUILD_FLAVOR is used.
If no flavor is specified, stable is selected automatically.
Use TARGET_DIR to specify a different installation directory.
Use ENABLE_ARCHS to restrict the build to a supported set of architectures, for example "arm64 x86_64".
./build.sh
BUILD_FLAVOR=llvm ./build.sh
UNATTENDED=1 BUILD_FLAVOR=latest ./build.sh
TARGET_DIR=/usr/local/osxcross OSX_VERSION_MIN=XX.X ENABLE_ARCHS="<ARCHS>" ./build.sh
Add <target>/bin to your PATH after installation.
See README.BUILD-GCC.md for dependencies and instructions for
building the ARM64 Darwin GCC fork or vanilla GCC.
SDKs can be extracted either from the full Xcode or from the Xcode Command Line Tools.
See README.SDK.md for step-by-step instructions
on macOS and Linux.
i386-apple-darwinXX-clang++ test.cpp -O3 -o test (if your SDK supports i386)x86_64-apple-darwinXX-clang++ test.cpp -O3 -o testarm64-apple-darwinXX-clang++ test.cpp -O3 -o testarm64e-apple-darwinXX-clang++ test.cpp -O3 -o testOr by using xcrun:
xcrun clang++ -arch i386 test.cpp -O3 -o testxcrun clang++ -arch x86_64 test.cpp -O3 -o testxcrun clang++ -arch arm64 test.cpp -O3 -o testxcrun clang++ -arch arm64e test.cpp -O3 -o testGCC: Replace clang++ with g++ as needed
Check your target version with osxcross-conf, see TARGET.
xcrun -f clang prints the path to clang.
make CC=$(xcrun -f clang) CXX=$(xcrun -f clang++)
CC=x86_64-apple-darwinXX-clang CXX=x86_64-apple-darwinXX-clang++ ./configure --host=x86_64-apple-darwinXX
xcrun clang++ -stdlib=libc++ -std=c++11 test.cpp -o test
Shortcut:
x86_64-apple-darwinXX-clang++-libc++ -std=c++11 test.cpp -o test
xcrun clang++ test1.cpp -O3 -flto -c
xcrun clang++ test2.cpp -O3 -flto -c
xcrun clang++ -O3 -flto test1.o test2.o -o test
xcrun clang++ test.cpp -O3 -arch x86_64 -arch arm64 -o test
GCC:
xcrun g++ -arch x86_64 test.cpp -O3 -o test.x86_64
xcrun g++ -arch arm64 test.cpp -O3 -o test.arm64
xcrun lipo -create test.x86_64 test.arm64 -output test
Default:
Can be overriden via:
OSX_VERSION_MIN=XX.X ./build.sh.-mmacos-version-min=XX.X to the compiler.MACOSX_DEPLOYMENT_TARGET=XX.X env var.Note: Deployment target ≥ 10.9 defaults to libc++.
Can be explicitely overriden by setting the C++ library to libstdc++ via -stdlib=libstdc++.
The ppc-test branch is an older OSXCross branch with support for PowerPC targets.
scripts/wrapper: GPLv2cctools/ld64: APSL 2.0 (legacy)xar: New BSD(top 30 of 54)
C++
46.2%
Shell
39.1%
C
13.2%
OSXCross provides three build flavors:
stable (default):
cctools 986 and ld64 711.latest:
cctools 1030.6.3 and ld64 956.6.llvm:
ld64.lld instead of cctools and ld64.arm64, arm64e, and x86_64 targets. It does not support i386 or x86_64h.cctools lipo instead of llvm-lipo for improved compatibility.OSXCross provides a macOS cross-compilation toolchain.
OSXCross combines a host compiler, a packaged macOS SDK, Darwin-compatible binary utilities, and a compiler wrapper into a cross-compilation toolchain.
The selected build flavor determines which binary utilities and linker are used:
stable and latest flavors build
cctools-port, including tools
such as ar, lipo, and otool, together with the ld64 linker.llvm flavor uses the corresponding LLVM tools and ld64.lld. It can
optionally build cctools lipo as a compatibility replacement for llvm-lipo.During ./build.sh, the SDK is installed into the target directory, the tools
and dependencies required by the selected flavor are prepared, and the OSXCross
wrapper is compiled. The installed target-prefixed commands configure the target
triple, SDK sysroot, deployment target, and linker for macOS automatically.
Additional scripts can build optional compiler and runtime components:
./build_clang.sh)./build_apple_clang.sh)./build_gcc.sh)./build_gcc_with_arm64_support.sh)./build_compiler_rt.sh)A minimal MacPorts package manager is included. See README.MACPORTS.md.
For CMake projects, OSXCross provides architecture- and compiler-specific
launchers together with an installed toolchain file.
See README.CMAKE.md for setup, compiler selection, universal
binaries, package discovery, and complete examples.
Generate the SDK and place the resulting archive in the tarballs/ directory.
Install the OSXCross build dependencies:
See README.BUILD-DEPENDENCIES.md for required and optional dependencies,
Debian/Ubuntu installation commands, and the systems supported by tools/get_dependencies.sh.
Optionally, build a recent version of Clang and LLD:
See README.BUILD-CLANG.md for dependencies and instructions for building
upstream LLVM/Clang or Apple Clang.
By default, the OSXCross toolchain is installed in <current-directory>/target.
./build.sh prompts you to select a build flavor. Press Enter to use the default stable flavor.
Set BUILD_FLAVOR to stable, latest, or llvm to select a flavor without prompting.
When UNATTENDED=1 is set, the specified BUILD_FLAVOR is used.
If no flavor is specified, stable is selected automatically.
Use TARGET_DIR to specify a different installation directory.
Use ENABLE_ARCHS to restrict the build to a supported set of architectures, for example "arm64 x86_64".
./build.sh
BUILD_FLAVOR=llvm ./build.sh
UNATTENDED=1 BUILD_FLAVOR=latest ./build.sh
TARGET_DIR=/usr/local/osxcross OSX_VERSION_MIN=XX.X ENABLE_ARCHS="<ARCHS>" ./build.sh
Add <target>/bin to your PATH after installation.
See README.BUILD-GCC.md for dependencies and instructions for
building the ARM64 Darwin GCC fork or vanilla GCC.
SDKs can be extracted either from the full Xcode or from the Xcode Command Line Tools.
See README.SDK.md for step-by-step instructions
on macOS and Linux.
i386-apple-darwinXX-clang++ test.cpp -O3 -o test (if your SDK supports i386)x86_64-apple-darwinXX-clang++ test.cpp -O3 -o testarm64-apple-darwinXX-clang++ test.cpp -O3 -o testarm64e-apple-darwinXX-clang++ test.cpp -O3 -o testOr by using xcrun:
xcrun clang++ -arch i386 test.cpp -O3 -o testxcrun clang++ -arch x86_64 test.cpp -O3 -o testxcrun clang++ -arch arm64 test.cpp -O3 -o testxcrun clang++ -arch arm64e test.cpp -O3 -o testGCC: Replace clang++ with g++ as needed
Check your target version with osxcross-conf, see TARGET.
xcrun -f clang prints the path to clang.
make CC=$(xcrun -f clang) CXX=$(xcrun -f clang++)
CC=x86_64-apple-darwinXX-clang CXX=x86_64-apple-darwinXX-clang++ ./configure --host=x86_64-apple-darwinXX
xcrun clang++ -stdlib=libc++ -std=c++11 test.cpp -o test
Shortcut:
x86_64-apple-darwinXX-clang++-libc++ -std=c++11 test.cpp -o test
xcrun clang++ test1.cpp -O3 -flto -c
xcrun clang++ test2.cpp -O3 -flto -c
xcrun clang++ -O3 -flto test1.o test2.o -o test
xcrun clang++ test.cpp -O3 -arch x86_64 -arch arm64 -o test
GCC:
xcrun g++ -arch x86_64 test.cpp -O3 -o test.x86_64
xcrun g++ -arch arm64 test.cpp -O3 -o test.arm64
xcrun lipo -create test.x86_64 test.arm64 -output test
Default:
Can be overriden via:
OSX_VERSION_MIN=XX.X ./build.sh.-mmacos-version-min=XX.X to the compiler.MACOSX_DEPLOYMENT_TARGET=XX.X env var.Note: Deployment target ≥ 10.9 defaults to libc++.
Can be explicitely overriden by setting the C++ library to libstdc++ via -stdlib=libstdc++.
The ppc-test branch is an older OSXCross branch with support for PowerPC targets.
scripts/wrapper: GPLv2cctools/ld64: APSL 2.0 (legacy)xar: New BSD(top 30 of 54)
C++
46.2%
Shell
39.1%
C
13.2%