Cross compiling Apache Thrift for armhf

I am on x86, trying to cross-compile apache thrift program written in C ++ for armhf. I installed gcc-arm-linux-gnueabihf and g++-arm-linux-gnueabihf via apt-get , but when I use them to compile my program, I get

skipping incompatible /usr/local/lib/libthrift.so when searching for -lthrift

so I tried to configure thrift to compile armhf compatible libthrift.so using this guide , so in bash:

./configure CXX=arm-linux-gnueabihf-g++ CC=arm-linux-gnueabihf-gcc --prefix=/BBB/thrift --host=arm-linux-gnueabihf --with-cpp CFLAGS="-g -O2 -I$DIR/include" LDFLAGS="-L$DIR/lib

but then I got:

checking for libevent >= 1.0... configure: error: in 'home/xic/thrift-0.9.0': configure: error: cannot run test program while cross compiling

so I successfully compiled libevent , but it still won't work. Looking into the thrift config.log , I see

/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lfl collect2: ld returned 1 exit status

so apparently i also need to compile flex. Is this really the best way to do this, or are there any faster / easier ways?

ps. I cross compile for Beaglebone Black which uses armhf

+4
source share
2 answers

Thrift 0.9.0 is broken for cross-compiling - it received raftloads of static paths in an Autoconf test script.

There is a mistake in their Jira, but things have not gone very far (basically asking if I installed -includedir of all things ... (Hint: Cross compile does not use you using the Autotools configuration, and the first thing they had to do is this is to look for fixed paths from the host))

You cannot disable the PHP building, which spins even more. It’s a shame, indeed, I kind of needed a single store for this, and Google and the community as a whole threw the ball at it (RPC is a joke ... how many different implementations - and none of them supports C / C ++ / Python / C # is compatible at the same time ...).

+2
source

On my system, I installed libfl by running the following command, which should be simpler than manually cross-compiling flex.

 sudo xapt -a armhf -m libfl-dev 

To fix the problem cannot run test program while cross compiling , you can either build Thrift without libevent support (if this is an option for you) by moving --without-libevent to configure , or you can change aclocal/ax_lib_event.m4 , replacing using AC_RUN_IFELSE with AC_LINK_IFELSE . Note that you will need to make a similar change to aclocal/ax_lib_zlib.m4 if you do not go --without-zlib to configure . Remember to run autoconf after changing files in aclocal .

After making these changes, you are likely to come across these compilation errors:

/usr/arm-linux-gnueabihf/include/++/4.6.3/cstdlib: 119: 11: error: ':: malloc' not declared / usr / arm -linux-gnueabihf / include / c ++ / 4.6.3 / cstdlib: 127: 11: error: ':: realloc' was not declared

IMO, the easiest way to fix this is to remove the following lines from configure.ac :

 AC_FUNC_MALLOC AC_FUNC_REALLOC 

Again, you need to run autoconf after deleting the lines from configure.ac .

Finally, you can re-run configure with the options you selected. On my system, I ran:

 ./configure --host=arm-linux-gnueabihf --with-cpp --without-tests \ --without-qt4 --without-c_glib --without-ruby --without-python 

You will need the --without-tests option to avoid problems caused by a failure trying to run armhf test binaries on your x86 build machine.

I passed the remaining options --without-* to avoid having to install additional dependencies. If you do not require support for QT, Glib, Ruby, and Python, I recommend that you do the same to simplify the build.

+6
source

Source: https://habr.com/ru/post/1492835/


All Articles