【保姆级教程】在龙芯3A5000上编译arrow-0.15.1

环境信息

处理器:龙芯3C5000
操作系统:Loongnix Server 8.4.1
内核版本:4.19.190-6.5

1、arrow-0.15.1的编译参数

每家的参数不一样,可以根据自己需求更改。

2、生成makefile阶段报错信息

2.1 预备工作

首先系统中先安装cmake、make、gcc、gcc-c++这个软件包,然后开始编译,arrow使用cmake构建器,所以最好能对cmake了解一点(题外话,推荐的cmake书籍是《》)。

2.2 缺少boost相关库导致错误

2.2.1 错误信息:

ORC VERSION :.5.5
PROTOBUF VERSION :V3 .7.1
RAPIDJSON VERSION :2bbd33b33217ff4a73434ebf10cdac41e2ef5e34
RE2 VERSION :2019-08-01
SNAPPY VERSION :1.1.7
THRIFT VERSION :0 .12.0
THRIFT MD5 CHECKSUM :3deebbb4d1ca77dd9c9e009alea02183
URIPARSER VERSION :0.9.3
ZLIB VERSION :1.2.11
ZSTD VERSION :.4.3
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake :165 ( message):
Could NOT find Boost ( missing:regex system filesystem )(found suitable 
version "1.73.0",minimum required is "1.58")
Call stack (mostrecent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake :458 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake/Modules/FindBoost.cmake :2177 ( find_package_handle_standard_args)
cmake _modules/FindBoostAlt.cmake :49 ( find_package)
cmake _modules/ThirdpartyToolchain.cmake :643 ( find_package)
CMakeLists .txt :416 ( include)

2.2.2 原因及解决

报这个错的原因是因为系统里面默认没有安装boost软件包,所以只需要执行下面安装即可!

[loongson@bogon build]$ sudo yum install boost-devel

安装完成后继续执行cmake命令,然后继续报boost相关错误

2.2.3 错误信息

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR regex system filesystem)
(Required is at least version "1.58")
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:458(_FPHSA_FAILURE_MESSAG)
/usr/share/cmake/Modules/FindBoost.cmake :2177 ( find_package_handle_standard_args)
cmake_modules/FindBoostAlt.cmake:49 (find_package)
cmake_modules/ThirdpartyToolchain.cmake:643 (find_package)

2.2.4 原因及解决

前面已经安装了boost,居然还报错,检查了一下编译选项,发现其中有一项DARROW_BOOST_USE_SHARED=OFF ,这一项会导致使用boost静态库,然后目前系统中还没有安装对应的包,执行sudo yum install boost-static命令安装对应的boost静态库,然后继续执行cmake命令。

2.3 缺少double-conversion 导致错误

2.3.1 错误信息

project has asked CMake to find a package configuration file provided by
"double-conversion", but CMake did not find one.
Could not find a package configuration file provided by "double-conversion"
with any of the following names:
double-conversionConfig.cmake
double-conversion-config.cmake

2.3.2 解决方法

Loongnix Server 8.4中 double-conversion软件包位于epel仓库,首先安装epel仓库地址的包,然后再执行double-conversion安装:

[loongson@bogon build]$ sudo yum install loongnix-release-epel
[loongson@bogon build]$ sudo yum install double-conversion double-conversion-devel

2.4 缺少snappy导致错误

2.4.1 错误信息

DOUBLE_CONVERSION_HAS_CASE_INSENSIBILITY
-- Performing Test DOUBLE_CONVERSION_HAS_CASE_INSENSIBILITY - Success
Could NOT find Snappy ( missing:Snappy DIR )
CMake Error at / usr/ share/cmake/Modules/FindPackageHandleStandardArgs.cmake :165 ( message):
Could NOT find SnappyAlt ( missing:Snappy _LIBSnappy _INCLUDE_DIR)

2.4.2 解决方法

[loongson@bogon build]$ sudo yum install snappy-devel

2.5 缺少libglog导致错误

2.5.1 错误信息

- Building without OpenSSL support. Minimum OpenSSL version 1.0.2 required.
-- Checking for module 'libglog'
-- Package 'libglog', required by 'virtual:world', not found
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find GLOG (missing: GLOG_INCLUDE_DIR GLOG_LIB)

2.5.2 解决方法

Loongnix Server 8.4中,glog位于PowerTools仓库,所以需要先打开PowerTools仓库:

[loongson@bogon build]$ sudo vim /etc/yum.repos.d/Loongnix-PowerTools.repo

将其中的 enabled=0修改为 enabled=1

然后执行安装命令:

[loongson@bogon build]$ sudo yum install glog-devel

根据提示信息中openssl相关的内容,安装openssl-devel软件包。

2.6 缺少thrift导致错误

2.6.1 错误信息

-- Found libglog, version 0.3.5
-- Found GLOG: /usr/include
Checking for module ' thrift‘
-- Package  thrift',required by 'virtual:world, not found
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find Thrift (missing: THRIFT_STATIC_LIB THRIFT_INCLUDE_DIR THRIFT_COMPILER)
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
cmake_modules/FindThrift.cmake:89

2.6.2 解决方法

在Loongnix Server 8.4中,thrift位于storage下面的ceph-pacific仓库中,
1)可以按照如下方式配置这个仓库:

[loongson@bogon build]$ sudo vim /etc/yum.repos.d/Loongnix-storage.repo

仓库内容如下:

[pacific]
name=Loongnix server $releasever - ceph-pacific
baseurl=http://pkg.loongnix.cn/loongnix-server/$releasever/storage/$basearch/release/ceph-pacific/
gpgcheck=0
enabled=1
priority=4
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LOONGNIX

然后保存退出,在命令行执行安装软件包的命令:

[loongson@bogon build]$ sudo yum install thrift-devel

2.7 缺少protobuf导致错误

2.7.1 错误信息

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find Protobuf (missing:Protobuf _INCLUDE_DIR)( Requiredis at least version "2.6.1")
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:458(_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake/Modules/FindProtobuf.cmake:626 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake_modules/ThirdpartyToolchain.cmake:197 (find_package)
cmake_modules/ThirdpartyToolchain.cmake:1349 (resolve_dependency_with_version)

2.7.2 解决方法

[loongson@bogon build]$ sudo yum install protobuf-devel

然后继续执行cmake命令。还是出现protobuf相关错误,信息如下:

2.7.3 错误信息

-- ZLIB_VERSION: 1.2.11
-- ZSTD_VERSION: v1.4.3
-- Boost include dir: /usr/include
-- Boost libraries: /usr/1lib64/libboost_regex.a/usr/1ib64/libboost_system.a/usr/1ib64/libboost_filesystem.a
-- Could NOT find Snappy (missing: Snappy_DIR)
-- Building without OpenSSL support. Minimum OpenSSL version 1.0.2 required.
-- Found Protobuf: Protobuf_LIBRARY-NOTFOUND;-pthread (found suitable version "3.5.0", minimum required is "2.6.1")
CMake Error at cmake_modules/ThirdpartyToolchain.cmake:1372 (message):
libprotoc was set to Protobuf _PROTOC_LIBRARY-NOTFOUND
Call Stack ( mostrecent call first ):

2.7.4 解决方法

这个错误想了半天才找到原因,还是因为编译选项中禁止了protobuf的动态库,然后又忘了装protobuf的静态库导致的…

[loongson@bogon build]$ sudo yum install protobuf-static

2.8 缺少rapidjson导致错误

2.8.1 错误信息

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find RapidJSONALt (missing: RAPIDJSON_INCLUDE_DIR) (found
suitable version "2bbd33b33217ff4a73434ebf1l0cdac4le2ef5e34", minimum
required is "1.1.0")
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
cmake_modules/FindRapidJSONALt.cmake:56 (find_package_handle_standard_args)
cmake_modules/ThirdpartyToolchain.cmake:1776 (find_package)

2.8.2 解决方法

[loongson@bogon build]$ sudo yum install rapidjson-devel

2.9 缺少flatbuffers导致错误

2.9.1 错误信息

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find FlatbuffersAlt (missing: FLATBUFFERS_LIB
  FLATBUFFERS_INCLUDE_DIR FLATC)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  cmake_modules/FindFlatbuffersAlt.cmake:42 (find_package_handle_standard_args)
  cmake_modules/ThirdpartyToolchain.cmake:1846 (find_package)
  CMakeLists.txt:416 (include)

2.9.2 解决方法

Loongnix Server 8.4.1系统中没有flatbuffers这个包,需要从上游直接拉取源码进行编译。不过好在这个软件包一把可以编译通过,不需要做更改。
flatbuffers源码地址:https://github.com/google/flatbuffers.git

[loongson@bogon workspace]$ git clone https://github.com/google/flatbuffers.git
......
[loongson@bogon workspace]$ cd flatbuffers/
[loongson@bogon flatbuffers]$ mkdir build
[loongson@bogon flatbuffers]$ cd build
[loongson@bogon build]$ cmake ..
[loongson@bogon build]$ make -j32
[loongson@bogon build]$ ls
CMakeCache.txt       compile_commands.json             flatbuffers.pc  flatsamplebfbs    flattests          libflatbuffers.so.23.1.4  tests
CMakeFiles           CTestTestfile.cmake               flatc           flatsamplebinary  libflatbuffers.a   Makefile
cmake_install.cmake  flatbuffers-config-version.cmake  flathash        flatsampletext    libflatbuffers.so  samples

这样编译出来的flatbuffers默认只有静态库、而没有动态库,需要需要动态库的话,需要调整一下。编译完成之后,结果如上面ls所示。
将编译后的内容对应拷贝到系统相应目录下,如下:

# 在flatbuffers的build目录下:
[loongson@bogon build]$ sudo cp -a libflatbuffers.* /lib64/
[sudo] loongson 的密码:
[loongson@bogon build]$ sudo cp -a flatbuffers.pc /lib64/pkgconfig/
[loongson@bogon build]$ sudo cp flatc flathash flatsamplebfbs flatsamplebinary flatsampletext flattests /usr/bin/
[loongson@bogon build]$ sudo mkdir /usr/lib64/cmake/flatbuffers
# 注意这块儿切换了目录,来到了源码目录下的CMake目录下执行的命令!!!
[loongson@bogon CMake]$ sudo cp FindFlatBuffers.cmake /usr/lib64/cmake/flatbuffers/
[loongson@bogon CMake]$ sudo cp flatbuffers-config.cmake /usr/lib64/cmake/flatbuffers/

此处暂时没有拷贝头文件,后面用到再继续拷贝。继续cmake编译arrow

2.10 缺少liblz4导致错误

2.10.1 错误信息

-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.11") 
-- Checking for module 'liblz4'
--   Package 'liblz4', required by 'virtual:world', not found
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find Lz4 (missing: LZ4_LIB LZ4_INCLUDE_DIR)
Call Stack (most recent call first):

2.10.2 解决方法

[loongson@bogon build]$ sudo yum install lz4-devel

2.11 缺失re2导致错误

2.11.1 错误信息

--   Found liblz4, version 1.8.3
-- Found Lz4: /usr/lib64/liblz4.so  
-- Checking for module 're2'
--   Package 're2', required by 'virtual:world', not found
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find RE2 (missing: RE2_LIB RE2_INCLUDE_DIR)

2.11.2 解决方法

[loongson@bogon build]$ sudo yum install re2-devel

安装re2-devel同时会依赖安装re2,安装完成后执行cmake命令,还是继续报错,错误信息如下:

2.11.3 报错信息

-- Checking for module 're2'
--   Found re2, version 0.0.0
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find RE2 (missing: RE2_LIB)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  cmake_modules/FindRE2.cmake:62 (find_package_handle_standard_args)
  cmake_modules/ThirdpartyToolchain.cmake:184 (find_package)
  cmake_modules/ThirdpartyToolchain.cmake:2078 (resolve_dependency)
  CMakeLists.txt:416 (include)

2.11.4 解决方法

打开cmake的配置选项,在build目录下执行ccmake ..命令,然后翻到最后位置,将下面两项修改为如下内容(RE2_LIB的内容可以通过rpm -ql re2-devel查看到)。
修改re2的配置信息

2.12 依赖llvm 7.1版本导致错误

2.12.1 错误信息

CMake Error at cmake_modules/FindLLVM.cmake:34 (find_package):
  Could not find a configuration file for package "LLVM" that is compatible
  with requested version "7.1".
  The following configuration files were considered but not accepted:
    /usr/lib64/cmake/llvm/LLVMConfig.cmake, version: 8.0.1
    /lib64/cmake/llvm/LLVMConfig.cmake, version: 8.0.1

2.12.2 解决方法

你如果编译到这一步可能和我的信息不是很一致,因为我之前已经安装了llvm-8.0.1,所以有找到llvm软件包,只是版本不匹配。

这个错误的原因是目前系统中支持的LLVM版本为8.0.1,而arrow-0.15.1需要的版本是7.1。7.1支持的功能没道理在8.0.1不支持,所以修改CMakeLists.txt文件中llvm的版本信息,让它匹配8.0.1。

[loongson@bogon build]$ vim ../CMakeLists.txt

 91 set(ARROW_LLVM_VERSION "7.0")
 92 # TODO: Remove this when we drop LLVM 7 support.
 93 set(ARROW_LLVM_VERSION_FALLBACK "7.1")

修改为

 91 set(ARROW_LLVM_VERSION "8.0.1")
 92 # TODO: Remove this when we drop LLVM 7 support.
 93 set(ARROW_LLVM_VERSION_FALLBACK "8.0.1")

修改完之后,继续执行cmake编译命令,报错信息如下:

2.12.3 错误信息

CMake Error at src/arrow/ipc/CMakeLists.txt:65 (get_target_property):
  get_target_property() called with non-existent target "flatbuffers::flatc".
-- flatc: 
CMake Error at /usr/lib64/cmake/llvm/LLVMExports.cmake:1059 (message):
  The imported target "LLVMDemangle" references the file
     "/usr/lib64/libLLVMDemangle.a"
  but this file does not exist.  Possible reasons include:

2.12.4 解决方法

这块儿报错显示了没有找到静态库,所以安装llvm的静态库

[loongson@bogon build]$ sudo yum install llvm-static

2.13 去掉sse和simd支持

根据/home/loongson/workspace/arrow-apache-arrow-0.15.1/cpp/build/CMakeFiles/CMakeError.log中的报错信息,关掉这两个支持。
因为这两个都是X86支持的指令集,在LoongArch架构中并不支持,所以需要禁用。
在编译选项中加上下面两个:

-DARROW_SSE42=OFF \
-DARROW_USE_SIMD=OFF \

2.14 flatbuffers报错

2.14.1 错误信息

CMake Error at cmake_modules/ThirdpartyToolchain.cmake:1880 (get_target_property):
  get_target_property() called with non-existent target
  "flatbuffers::flatbuffers".
Call Stack (most recent call first):
  CMakeLists.txt:416 (include)


-- Found hdfs.h at: /home/loongson/workspace/arrow-apache-arrow-0.15.1/cpp/thirdparty/hadoop/include/hdfs.h
-- CMAKE_C_FLAGS: -fPIC -O3 -DNDEBUG   -Wall
-- CMAKE_CXX_FLAGS:  -Wno-noexcept-type -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -fdiagnostics-color=always -O3 -DNDEBUG  -Wall 
CMake Error at src/arrow/ipc/CMakeLists.txt:63 (get_target_property):
  get_target_property() called with non-existent target "flatbuffers::flatc".


CMake Error at src/arrow/ipc/CMakeLists.txt:65 (get_target_property):
  get_target_property() called with non-existent target "flatbuffers::flatc".

2.14.2 解决方法

⊙▂⊙,前面手长了,添加了这个信息(cmake知识需要再进一步),然后把它删了。

sudo rm -rf /usr/lib64/cmake/flatbuffers

2.15 错误

2.15.1 错误信息

好多类似的错误,

CMake Error in src/arrow/CMakeLists.txt:
  Found relative path while evaluating include directories of "arrow_objlib":

    "RAPIDJSON_INCLUDE_DIR-NOTFOUND"

2.15.2 解决方法

在cmake配置选项中添加
-DRAPIDJSON_INCLUDE_DIR=/usr/include/rapidjson

继续执行cmake命令,谢天谢地,终于生成Makefile了!

3 make阶段错误解决

3.1 缺少parquet_constants.cpp文件

3.1.1 错误信息

[ 66%] Building CXX object src/parquet/CMakeFiles/parquet_objlib.dir/parquet_constants.cpp.o
c++: error: /home/loongson/workspace/arrow-apache-arrow-0.15.1/cpp/src/parquet/parquet_constants.cpp: No such file or directory
c++: fatal error: no input files
compilation terminated.

3.1.2 解决方法

从arrow最新版里面拷贝parquet_constants.cpp和parquet_constants.h文件到对应目录下。

3.2 python未找到

3.2.1 错误信息

/bin/sh: python: 未找到命令
make[2]: *** [src/gandiva/precompiled/CMakeFiles/precompiled.dir/build.make:96:src/gandiva/precompiled_bitcode.cc] 错误 127
make[1]: *** [CMakeFiles/Makefile2:1786:src/gandiva/precompiled/CMakeFiles/precompiled.dir/all] 错误 2

3.2.2 解决方法

Loongnix Server 8.4.1中默认Python为Python3.6版本,其创建 链接为
python3,所以手动给它创建python的软连接

[loongson@bogon cpp]$ sudo ln -s /usr/bin/python3.6 /usr/bin/python

3.3 /usr/bin/ld: 找不到 -ltinfo

3.3.1 错误信息

[100%] Linking CXX shared library ../../build/release/libgandiva.so
/usr/bin/ld: 找不到 -ltinfo
collect2: error: ld returned 1 exit status
make[2]: *** [src/gandiva/CMakeFiles/gandiva_shared.dir/build.make:207:build/release/libgandiva.so.15.1.0] 错误 1
make[1]: *** [CMakeFiles/Makefile2:1592:src/gandiva/CMakeFiles/gandiva_shared.dir/all] 错误 2

3.3.2 解决方法

[loongson@bogon cpp]$ sudo yum install ncurses-devel
posted @ 2023-01-12 19:31  streamlet_hy  阅读(304)  评论(0编辑  收藏  举报  来源