默认情况下,Parquet链接到Arrow的共享库。如果您希望静态链接箭头符号,请传递-DPARQUET_ARROW_LINKAGE = static。
我确实希望静态链接Arrow,因为我想在其他没有安装Arrow的服务器上使用我的程序。我尝试了-DPARQUET_ARROW_LINKAGE=static
,但我收到了关于"错过传递依赖关系的错误":
# cmake -DPARQUET_BUILD_TESTS=Off -DCMAKE_BUILD_TYPE=Release -DPARQUET_MINIMAL_DEPENDENCY=ON -DPARQUET_ARROW_LINKAGE=static .
-- The C compiler identification is GNU 4.8.5
...
-- [ /usr/local/share/cmake-3.9/Modules/FindBoost.cmake:1717 ] Boost_FOUND = 1
-- Boost version: 1.55.0
...
-- THRIFT_HOME:
-- Thrift compiler/libraries NOT found: (THRIFT_INCLUDE_DIR-NOTFOUND, THRIFT_STATIC_LIB-NOTFOUND). Looked in system search paths.
-- Thrift include dir: /root/tmp/parquet-cpp-master/thrift_ep/src/thrift_ep-install/include
-- Thrift static library: /root/tmp/parquet-cpp-master/thrift_ep/src/thrift_ep-install/lib/libthrift.a
-- Thrift compiler: /root/tmp/parquet-cpp-master/thrift_ep/src/thrift_ep-install/bin/thrift
-- Checking for module 'arrow'
-- No package 'arrow' found
-- Could not find the Arrow library. Looked for headers in , and for libs in
-- Building Apache Arrow from commit: 501d60e918bd4d10c429ab34e0b8e8a87dffb732
-- CMAKE_CXX_FLAGS: -O3 -DNDEBUG -Wall -std=c++11
-- Found cpplint executable at /root/tmp/parquet-cpp-master/build-support/cpplint.py
CMake Error at CMakeLists.txt:515 (message):
Missing transitive dependencies for Arrow static linking
所以我found the code会产生错误:
if (NOT DEFINED ENV{BROTLI_STATIC_LIB_ENC} OR
NOT DEFINED ENV{BROTLI_STATIC_LIB_DEC} OR
NOT DEFINED ENV{BROTLI_STATIC_LIB_COMMON} OR
NOT DEFINED ENV{SNAPPY_STATIC_LIB} OR
NOT DEFINED ENV{ZLIB_STATIC_LIB} OR
NOT DEFINED ENV{LZ4_STATIC_LIB} OR
NOT DEFINED ENV{ZSTD_STATIC_LIB})
message(FATAL_ERROR "Missing transitive dependencies for Arrow static linking")
但这对我没有帮助,因为我不知道如何定义这些环境变量。
我是否需要先编译Arrow并自行安装? (我宁愿让实木复合地板给我做。)
答案 0 :(得分:4)
我安排了一个脚本来下载依赖项源代码,设置环境变量并在最后运行cmake
行。只需更改DEPDIR变量值,将其设置为所选目录。
#!/bin/bash
CMKDIR=$PWD
DEPDIR=/tmp
cd $DEPDIR
#snappy
git clone https://github.com/google/snappy.git
cd snappy
mkdir build
cd build
cmake ..
make
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
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
make
export ZLIB_STATIC_LIB=$DEPDIR/zlib/libz.a
cd $DEPDIR
#lz4
git clone https://github.com/lz4/lz4.git
cd lz4
make
export LZ4_STATIC_LIB=$DEPDIR/lz4/lib/liblz4.a
cd $DEPDIR
#zstd
git clone https://github.com/facebook/zstd.git
cd zstd
make
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
此脚本非常简单,但应该有效。只需将其复制到一个新文件中(在相同的CMakeLists.txt目录中),为该文件提供执行权限(即sudo chmod +x filename
)并执行它,如下所示:
./filename.sh
关于 fPIC选项问题,您必须编辑一些文件:
snappy :在前两行之后的CMakeLists.txt中添加此行:
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
lz4 和 zstd :在此行之后编辑lib子目录中的Makefile
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
添加以下行:
CFLAGS += -fPIC
zlib :在此行之后编辑Makefile
CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
添加以下行:
CFLAGS += -fPIC
brotli :就我从make输出中看到的那样,该选项已经设置好了。
再次运行make之前,请执行以下脚本:
#!/bin/bash
DEPDIR=/tmp
cd $DEPDIR/snappy/build
cmake ..
make clean
make
cd $DEPDIR/lz4
make clean
make
cd $DEPDIR/zstd
make clean
make