ClickHouse/docs/zh/development/build_cross_osx.md
Ivan 8d021b31fb
Fix docs for build-cross-osx and build-cross-arm64 (#7821)
* Fix docs for build-cross-osx and build-cross-arm64
* Fix links from ru and zh
* Update docs/en/development/build_cross_arm.md
2019-12-02 17:00:21 +03:00

1.7 KiB
Raw Blame History

如何在Linux中编译Mac OS X ClickHouse

Linux机器也可以编译运行在OS X系统的clickhouse二进制包这可以用于在Linux上跑持续集成测试。如果要在Mac OS X上直接构建ClickHouse请参考另外一篇指南 https://clickhouse.yandex/docs/zh/development/build_osx/

Mac OS X的交叉编译基于以下构建说明请首先遵循它们。

Install Clang-8

按照https://apt.llvm.org/中的说明进行Ubuntu或Debian安装。 例如安装Bionic的命令如下

sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list
sudo apt-get install clang-8

安装交叉编译工具集

我们假设安装 cctools 在 ${CCTOOLS} 路径下

mkdir ${CCTOOLS}

git clone https://github.com/tpoechtrager/apple-libtapi.git
cd apple-libtapi
INSTALLPREFIX=${CCTOOLS} ./build.sh
./install.sh
cd ..

git clone https://github.com/tpoechtrager/cctools-port.git
cd cctools-port/cctools
./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin
make install

cd ${CCTOOLS}
wget https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz
tar xJf MacOSX10.14.sdk.tar.xz

编译 ClickHouse

cd ClickHouse
mkdir build-osx
CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_SYSTEM_NAME=Darwin \
    -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \
    -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \
    -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld \
    -DSDK_PATH=${CCTOOLS}/MacOSX10.14.sdk
ninja -C build-osx

生成的二进制文件将具有Mach-O可执行格式并且不能在Linux上运行。