Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to build parquet-cpp with Arrow as a static dependency
#! /usr/bin/env bash
# Script to build parquet-cpp with Arrow as a static dependency
# Modified from:
# https://stackoverflow.com/questions/48157198/how-can-i-statically-link-arrow-when-building-parquet-cpp
mkdir -p parquet-cpp-deps
DEPDIR=$PWD/parquet-cpp-deps
git clone https://github.com/apache/parquet-cpp
cd arrow/cpp
sed -i 's$http://archive.apache.org/dist/thrift$http://apache.cs.utah.edu/thrift$g' cmake_modules/ThirdpartyToolchain.cmake
mkdir build
cd build
CMKDIR=$PWD
cd $DEPDIR
rm -rf snappy brotli zlib lz4 zstd
#snappy
git clone https://github.com/google/snappy.git
cd snappy
# For -fPIC support
sed -n -i 'p;3a set(CMAKE_POSITION_INDEPENDENT_CODE ON)' CMakeLists.txt
mkdir build
cd build
cmake ..
make -j4
export SNAPPY_STATIC_LIB=$DEPDIR/snappy/build/libsnappy.a
cd $DEPDIR
#brotli
git clone https://github.com/google/brotli.git
cd brotli
mkdir out
cd out
../configure-cmake
make -j4
export BROTLI_STATIC_LIB_ENC=$DEPDIR/brotli/out/libbrotlienc-static.a
export BROTLI_STATIC_LIB_DEC=$DEPDIR/brotli/out/libbrotlidec-static.a
export BROTLI_STATIC_LIB_COMMON=$DEPDIR/brotli/out/libbrotlicommon-static.a
cd $DEPDIR
#zlib
git clone https://github.com/madler/zlib.git
cd zlib
./configure
sed -i '/CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN/a CFLAGS += -fPIC' Makefile
make -j4
export ZLIB_STATIC_LIB=$DEPDIR/zlib/libz.a
cd $DEPDIR
#lz4
git clone https://github.com/lz4/lz4.git
cd lz4
sed -i '/CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)/a CFLAGS += -fPIC' lib/Makefile
make -j4
export LZ4_STATIC_LIB=$DEPDIR/lz4/lib/liblz4.a
cd $DEPDIR
#zstd
git clone https://github.com/facebook/zstd.git
cd zstd
sed -i '/CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)/a CFLAGS += -fPIC' lib/Makefile
make -j4
export ZSTD_STATIC_LIB=$DEPDIR/zstd/lib/libzstd.a
cd $CMKDIR
cmake .. -DPARQUET_BUILD_TESTS=Off -DCMAKE_BUILD_TYPE=Release -DPARQUET_MINIMAL_DEPENDENCY=ON -DPARQUET_ARROW_LINKAGE=static
make -j4
#! /usr/bin/env bash
# Script to build parquet-cpp with Arrow as a static dependency
# Modified from:
# https://stackoverflow.com/questions/48157198/how-can-i-statically-link-arrow-when-building-parquet-cpp
mkdir -p parquet-cpp-deps
DEPDIR=$PWD/parquet-cpp-deps
git clone https://github.com/apache/parquet-cpp
cd parquet-cpp
sed -i '.bak' 's$http://archive.apache.org/dist/thrift$http://apache.cs.utah.edu/thrift$g' cmake_modules/ThirdpartyToolchain.cmake
rm cmake_modules/ThirdpartyToolchain.cmake.bak
mkdir build
cd build
CMKDIR=$PWD
cd $DEPDIR
rm -rf snappy brotli zlib lz4 zstd
#snappy
git clone https://github.com/google/snappy.git
cd snappy
# For -fPIC support
sed -n -i '.bak' 'p;3a\'$'\n''set(CMAKE_POSITION_INDEPENDENT_CODE ON)'$'\n' CMakeLists.txt
rm CMakeLists.txt.bak
mkdir build
cd build
cmake ..
make -j3
export SNAPPY_STATIC_LIB=$DEPDIR/snappy/build/libsnappy.a
cd $DEPDIR
#brotli
git clone https://github.com/google/brotli.git
cd brotli
mkdir out
cd out
../configure-cmake
make -j3
export BROTLI_STATIC_LIB_ENC=$DEPDIR/brotli/out/libbrotlienc-static.a
export BROTLI_STATIC_LIB_DEC=$DEPDIR/brotli/out/libbrotlidec-static.a
export BROTLI_STATIC_LIB_COMMON=$DEPDIR/brotli/out/libbrotlicommon-static.a
cd $DEPDIR
#zlib
git clone https://github.com/madler/zlib.git
cd zlib
./configure
sed -i '.bak' '/CFLAGS=-O3 -DHAVE_HIDDEN/a\'$'\n'' CFLAGS += -fPIC'$'\n' Makefile
rm Makefile.bak
make -j3
export ZLIB_STATIC_LIB=$DEPDIR/zlib/libz.a
cd $DEPDIR
#lz4
git clone https://github.com/lz4/lz4.git
cd lz4
sed -i '.bak' '/CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)/a\'$'\n'' CFLAGS += -fPIC'$'\n' lib/Makefile
rm lib/Makefile.bak
make -j3
export LZ4_STATIC_LIB=$DEPDIR/lz4/lib/liblz4.a
cd $DEPDIR
#zstd
git clone https://github.com/facebook/zstd.git
cd zstd
sed -i '.bak' '/CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)/a\'$'\n'' CFLAGS += -fPIC'$'\n' lib/Makefile
rm lib/Makefile.bak
make -j3
export ZSTD_STATIC_LIB=$DEPDIR/zstd/lib/libzstd.a
cd $CMKDIR
cmake .. -DPARQUET_BUILD_TESTS=Off -DCMAKE_BUILD_TYPE=Release -DPARQUET_MINIMAL_DEPENDENCY=ON -DPARQUET_ARROW_LINKAGE=static
make -j3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.