arm_linuxクロスコンパイル開発環境構築-thrift

10193 ワード

thrift arm_linuxクロスコンパイル環境構築


1 linuxホストthrift環境


linux: Ubuntu 16.04

2依存パッケージ


sudo apt-get install automake sudo apt install bison sudo apt install flex sudo apt install libboost1.58-all-dev sudo apt install libevent-dev sudo apt install libssl-dev sudo apt install pkg-config

3 build host thrift


ダウンロードソース:wgethttp://archive.apache.org/dist/thrift/0.9.3/thrift-0.9.3.tar.gz tar -pxzf thrift-0.9.3.tar.gz
./configure --prefix=/usr/local/thrift --without-java --without-php --without-python make sudo make install

4 build arm thrift


依存パケットをクロスコンパイルする必要がある:boost 1.58 libevent2.0.22 openssl1.0.2l automake1.15(aclocal 1.14が必要というバージョンエラーメッセージがあり、スクリプトの中でスクリプトを判断する位置を変更し、1.15に変更する必要があります.1.14は使用できないためです)

4.1 build boost for arm


必要な依存パッケージ:apt-get install libicu-dev#正規表現をサポートするUNICOD文字セットapt-get install python-dev apt-get install libbz 2-dev#コンパイルにエラーが発生した場合:bzlib.h:No such file or directory(このエラーは難しい)コピーbzlib.hから./libs/iostreams/src/ディレクトリの下でboostソースをダウンロード:wgethttps://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2/download tar -pxjf boost_1_58_0.tar.bz2 cd boost_1_58_0.tar.bz 2運転:(1)実行./bootstrap.sh(2)生成するproject-configを修正する.JAmは以下の通り:using gcc:arm:arm-linux-gcc;注意:上のスペースは必須です.if ! gcc in [ feature.values ] { using gcc : arm : arm-linux-gcc ; } 次のように変更します.
# These settings are equivivalent to corresponding command-line
# options.
option.set prefix : /usr/local/arm/4.8.2 ;
option.set exec-prefix : /usr/local/arm/4.8.2/bin ;
option.set libdir : /usr/local/arm/4.8.2/lib ;
option.set includedir : /usr/local/arm/4.8.2/include ;

(3)./bjam stage --layout=tagged --build-type=complete link=shared runtime-link=shared threading=multi --without-python
stage/install:stageはライブラリ(dllとlib)のみを生成し、installはヘッダファイルを含むincludeディレクトリも生成します.stageを使用することをお勧めします.installが生成したこのincludeディレクトリは、実際にはboostインストールパッケージを解凍したboostディレクトリ(/arm-linux/src/thrift-arm/boost_1_58_0/boostであり、includeディレクトリよりも非hppファイルがいくつか多いだけで、小さい)なので、直接使用することができ、IDEによって同じヘッダファイルを使用することができ、コンパイル時間を節約し、ハードディスク領域を節約することができます.
toolset:borland、gcc、msvc(VC 6)、msvc-9.0(VS 2008)などのコンパイラを指定します.–without/with:コンパイル/コンパイルしないライブラリを選択します.python、mpiなどのライブラリは使いませんので除外します.そしてwave、graph、math、regex、test、program_options、serialization、signalsのいくつかのライブラリで作成された静的libは非常に大きいので、不要なものもwithoutしてもいいです.デフォルトはすべてコンパイルされます.ただし、pythonのコンパイルを選択すると、python言語のサポートが必要になります.python公式ホームページにアクセスする必要があります.http://www.python.org/インストールをダウンロードします.boostに含まれるライブラリを表示するコマンドはbjam--show-librariesです.
stagedir/prefix:stageではstagedir、installではprefixを使用し、生成ファイルをコンパイルするパスを表します.
build-dir:生成された中間ファイルのパスをコンパイルします.デフォルトでは、ルートディレクトリ(/arm-linux/src/thrift-arm/boost_1_58_0/)でbinというディレクトリ名が付けられています.v 2は、コンパイルが完了するとこのディレクトリをすべて削除できるので、設定する必要はありません.
link:ダイナミックリンクライブラリ/静的リンクライブラリを生成します.ダイナミックリンクライブラリの生成にはshared方式、静的リンクライブラリの生成にはstatic方式が必要です.
runtime-link:動的/静的リンクC/C++ランタイムライブラリ.同様にsharedとstaticの2つの方式があり、runtime-linkとlinkは全部で4つの組み合わせ方式を生成することができ、各人は自分の必要に応じてコンパイルを選択することができる.一般にlinkはstaticのみを選択すると、link=static runtime-link=sharedとlink=static runtime-link=staticの2つの組み合わせをコンパイルするだけでよい.
threading:単一/マルチスレッドコンパイル.マルチスレッドプログラムの場合はmulti方式を指定する必要があります.debug/release:debug/releaseバージョンをコンパイルします.

4.2 build libevent for arm

wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
tar -pxzf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/usr/local/arm/libevent --host=arm-linux CC=arm-linux-gcc CXX=arm-linux-g++
make
sudo make install

4.3 build openssl for arm

wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
tar -pxzf openssl-1.0.2l.tar.gz
cd openssl-1.0.2l
./config no-asm shared --prefix=/usr/local/arm/arm-openssl --openssldir=/usr/local/arm/arm-openssl --cross-compile-prefix=arm-linux-

修正Makefile:CC=arm-linux-gcc AR=arm-linux-arRANLIB=arm-linux-ranlib
make
sudo make install

よくあるエラー:(1)'OSSL_SSIZE_MAX'undeclared(バージョン1.1.0でこのエラーが発生)ソースコードの変更:include/openssl/e_os2.hの中のこの部分はこのように変更されました.
# ifndef ossl_ssize_t
#  define ossl_ssize_t ssize_t
#  if defined(SSIZE_MAX)
#   define OSSL_SSIZE_MAX SSIZE_MAX
#  elif defined(_POSIX_SSIZE_MAX)
#   define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX
/***      :   ***/
#  elif(__WORDSIZE == 64)              
#   define OSSL_SSIZE_MAX LONG_MAX
#  elif(__WORDSIZE == 32)
#   define OSSL_SSIZE_MAX INT_MAX    
/***      :   ***/
#  endif
# endif

(2)Linuxでopensslをインストール、configとmakeを実行した後、make installを実行するときに次のエラーが発生する場合cms.pod around line 457: Expected text after =item, not a number cms.pod around line 461: Expected text after =item, not a number cms.pod around line 465: Expected text after =item, not a number cms.pod around line 470: Expected text after =item, not a number cms.pod around line 474: Expected text after =item, not a number POD document had syntax errors at/usr/bin/pod2man line 69. root権限の下でsudo mv/usr/bin/pod 2 man/usr/bin/pod 2 man_を実行します.bakはその後、再びmake installがinstallを完了した後、このファイルを復元します.
sudo mv /usr/bin/pod2man_bak /usr/bin/pod2man

4.4 build zlib for arm


zlib-1.2.11
export CC=arm-linux-gcc
./configure --prefix=/usr/local/arm/zlib
make
sudo make install

4.5 build thrift for arm


ソースの再解凍:
mkdir thrift-arm
tar -pxzf thrift-0.9.3.tar.gz -C src/thrift-arm

thrift arm環境ではlimitsが1つ欠けている.hファイル:
cp /usr/include/limits.h thrift/compiler/cpp/src    

QtCoreを設定する.PCのパス:
export PKG_CONFIG_PATH=/usr/local/worksch/qt486-arm/lib/pkgconfig

configureを編集します.acファイル、中の2行を削除します:
AC_FUNC_MALLOC
AC_FUNC_REALLOC

次に、
autoconf
export PKG_CONFIG_PATH=/usr/local/worksch/qt486-arm/lib/pkgconfig
./configure --target=arm-linux --host=arm-linux --prefix=/usr/local/arm/thrift --with-boost=/home/haojc/arm-linux/src/thrift-arm/boost_1_58_0/stage --with-libevent=/usr/local/arm/libevent --with-openssl=/usr/local/arm/arm-openssl LDFLAGS="-L/home/haojc/arm-linux/src/thrift-arm/boost_1_58_0/stage/lib -L/usr/local/arm/libevent/lib -lcrypto -L/usr/local/arm/arm-openssl/lib -L/usr/local/arm/zlib/lib" LIBS="-ldl" CXXFLAGS="-I/home/haojc/arm-linux/src/thrift-arm/boost_1_58_0 -I/usr/local/arm/arm-openssl/include -I/usr/local/arm/libevent/include -I/usr/local/arm/4.8.2/arm-linux-gnueabi/include -I/usr/local/arm/4.8.2/include -I/usr/local/arm/zlib/include" --enable-tests=no --with-qt4=yes --with-qt5=no QT_LIBS="-L/usr/local/worksch/qt486-arm/lib" --with-zlib=/usr/local/arm/zlib

make
sudo make install

よくある質問:(1)aclocal 1.14,automake 1.14が欠けている場合は、スクリプトの中でスクリプトを判断する場所を変更します.Automake 2.15でいいです.