protobuf/lib: pread failed: is a directory, cross-compilation, deploy client application to Android phone
-
I have managed to cross compile protobuf 2.5.0 for arm-linux-androideabi with this script:
#!/bin/bash export NDK=/media/qt5-qwt6/ndk10/android-ndk-r10e export SYSROOT=$NDK/platforms/android-21/arch-arm export TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 export PATH=$PATH:$TOOLCHAIN/bin export CC="$TOOLCHAIN/bin/arm-linux-androideabi-gcc --sysroot $SYSROOT" export CXX="$TOOLCHAIN/bin/arm-linux-androideabi-g++ --sysroot $SYSROOT" export CXXSTL=$NDK/sources/cxx-stl/gnu-libstdc++/4.9 function build_one { mkdir build ./configure --prefix=$(pwd)/build \ --host=arm-linux-androideabi \ --with-sysroot=$SYSROOT \ --enable-static \ --disable-shared \ --enable-cross-compile \ --with-protoc=protoc \ CFLAGS="-march=armv7-a" \ CXXFLAGS="-march=armv7-a -I$CXXSTL/include -I$CXXSTL/libs/armeabi-v7a/include -L$CXXSTL/libs/armeabi-v7a/ -lgnustl_static" make clean make make install } # pwd is current directory CPU=arm PREFIX=$(pwd)/android/$CPU ADDI_CFLAGS="-marm" build_one # Inspect the library architecture specific information # arm-linux-androideabi-readelf -A build/lib/libprotobuf-lite.a
find for protoc delivers:
/home/staff/Desktop/protobuf/protobuf-2.5.0/build/bin/protoc: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
next step, I linked to the libraries in my Qt project in .pri file:
#Protobuf support (arm compiled) LIBS += -L/home/staff/Desktop/protobuf/protobuf-2.5.0/build/lib -lprotobuf INCLUDEPATH += /home/staff/Desktop/protobuf/protobuf-2.5.0/build/include
#qwt support (armv7) LIBS += -L/media/qt5-qwt6/lib -lqwt INCLUDEPATH += /media/qt5-qwt6/include #Bonjour/Avahi support LIBS += -L/usr/lib64/libdns_sd.so.1.0.0 #Protobuf support (arm compiled) LIBS += -L/home/staff/Desktop/protobuf/protobuf-2.5.0/build/lib -lprotobuf INCLUDEPATH += /home/staff/Desktop/protobuf/protobuf-2.5.0/build/include
When I try to run the project on my phone, protobuf is found but I get the following errors:
/media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: warning: skipping incompatible /home/staff/Qt5.8.0/5.8/android_armv7/lib/libqwt.so while searching for qwt /media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: warning: skipping incompatible /media/qt5-qwt6/lib/libqwt.so while searching for qwt /media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lqwt /media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldns_sd ../sozius-client/so_bonjourservicebrowser.cpp:57: error: undefined reference to 'DNSServiceRefDeallocate' ../sozius-client/so_bonjourservicebrowser.cpp:92: error: undefined reference to 'DNSServiceBrowse' ../sozius-client/so_bonjourservicebrowser.cpp:103: error: undefined reference to 'DNSServiceRefSockFD' ../sozius-client/so_bonjourservicebrowser.cpp:138: error: undefined reference to 'DNSServiceProcessResult' ../sozius-client/so_bonjourserviceresolver.cpp:79: error: undefined reference to 'DNSServiceRefDeallocate' ../sozius-client/so_bonjourserviceresolver.cpp:121: error: undefined reference to 'DNSServiceResolve' ../sozius-client/so_bonjourserviceresolver.cpp:132: error: undefined reference to 'DNSServiceRefSockFD' ../sozius-client/so_bonjourserviceresolver.cpp:169: error: undefined reference to 'DNSServiceProcessResult' ../sozius-client/so_bonjourservicereconfirmer.cpp:46: error: undefined reference to 'DNSServiceQueryRecord' ../sozius-client/so_bonjourservicereconfirmer.cpp:57: error: undefined reference to 'DNSServiceRefSockFD' ../sozius-client/so_bonjourservicereconfirmer.cpp:104: error: undefined reference to 'DNSServiceProcessResult' ../sozius-client/so_bonjourservicereconfirmer.cpp:122: error: undefined reference to 'DNSServiceConstructFullName' ../sozius-client/so_bonjourservicereconfirmer.cpp:140: error: undefined reference to 'DNSServiceRefDeallocate' ../sozius-client/so_bonjourservicereconfirmer.cpp:161: error: undefined reference to 'DNSServiceReconfirmRecord' ../sozius-client/so_bonjourservicequeryrecord.cpp:84: error: undefined reference to 'DNSServiceQueryRecord' ../sozius-client/so_bonjourservicequeryrecord.cpp:99: error: undefined reference to 'DNSServiceRefSockFD' ../sozius-client/so_bonjourservicequeryrecord.cpp:133: error: undefined reference to 'DNSServiceProcessResult' ../sozius-client/so_bonjourservicequeryrecord.cpp:145: error: undefined reference to 'DNSServiceRefDeallocate' ../sozius-client/so_bonjourservice.cpp:43: error: undefined reference to 'TXTRecordGetCount' ../sozius-client/so_bonjourservice.cpp:47: error: undefined reference to 'TXTRecordGetItemAtIndex' ../sozius-client/so_bonjourservice.cpp:229: error: undefined reference to 'DNSServiceConstructFullName' ../sozius-client/so_infograph_p.cpp:61: error: undefined reference to 'QwtPlot::setAxisTitle(int, QString const&)' ../sozius-client/so_infograph_p.cpp:99: error: undefined reference to 'QwtPlot::setFooter(QString const&)' ../sozius-client/so_infograph_p.cpp:135: error: undefined reference to 'QwtPlot::setAxisScale(int, double, double, double)' ../sozius-client/so_infograph_p.cpp:152: error: undefined reference to 'QwtPlot::setAxisAutoScale(int, bool)' ../sozius-client/so_infograph_p.cpp:157: error: undefined reference to 'QwtPlot::setAxisAutoScale(int, bool)' ../sozius-client/so_infograph_p.cpp:158: error: undefined reference to 'QwtPlot::setAxisScale(int, double, double, double)' ../sozius-client/so_infograph_p.cpp:177: error: undefined reference to 'QwtPlot::setFooter(QString const&)' ../sozius-client/so_infograph_p.cpp:178: error: undefined reference to 'QwtPlot::setCanvasBackground(QBrush const&)' ../sozius-client/so_infograph_p.cpp:179: error: undefined reference to 'QwtPlot::setAxisTitle(int, QString const&)' ../sozius-client/so_infograph_p.cpp:182: error: undefined reference to 'QwtPlot::setAxisScale(int, double, double, double)' ../sozius-client/so_infograph_p.cpp:183: error: undefined reference to 'QwtPlot::setAxisAutoScale(int, bool)' ../sozius-client/so_infograph_p.cpp:186: error: undefined reference to 'QwtPlot::setAxisScale(int, double, double, double)' ../sozius-client/so_infograph_p.cpp:201: error: undefined reference to 'QwtPlotCurve::QwtPlotCurve(QString const&)' ../sozius-client/so_infograph_p.cpp:203: error: undefined reference to 'QwtPlotCurve::setPen(QColor const&, double, Qt::PenStyle)' ../sozius-client/so_infograph_p.cpp:204: error: undefined reference to 'QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)' ../sozius-client/so_infograph_p.cpp:248: error: undefined reference to 'QwtPlotCurve::setSamples(QVector<QPointF> const&)' ../sozius-client/so_infograph_p.cpp:249: error: undefined reference to 'QwtPlotItem::attach(QwtPlot*)' ../sozius-client/so_qwtplot.cpp:3: error: undefined reference to 'QwtPlot::QwtPlot(QWidget*)' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::metaObject() const' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::qt_metacast(char const*)' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::qt_metacall(QMetaObject::Call, int, void**)' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::event(QEvent*)' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::eventFilter(QObject*, QEvent*)' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::resizeEvent(QResizeEvent*)' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::canvasMap(int) const' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::updateLayout()' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::drawCanvas(QPainter*)' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::getCanvasMarginsHint(QwtScaleMap const*, QRectF const&, double&, double&, double&, double&) const' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::drawItems(QPainter*, QRectF const&, QwtScaleMap const*) const' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::itemToInfo(QwtPlotItem*) const' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::infoToItem(QVariant const&) const' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:vtable for so_QwtPlot: error: undefined reference to 'QwtPlot::replot()' ../build/Linux/debug/.obj/so_qwtplot.o:so_qwtplot.cpp:typeinfo for so_QwtPlot: error: undefined reference to 'typeinfo for QwtPlot' ../sozius-client/so_qwtplot.h:9: error: undefined reference to 'QwtPlot::~QwtPlot()' /home/staff/Desktop/protobuf/protobuf-2.5.0/build/lib/libprotobuf.a(strutil.o):strutil.cc:function google::protobuf::safe_strtof(char const*, float*): error: undefined reference to 'strtof' collect2: error: ld returned 1 exit status make: *** [../build/Linux/debug/libsozius-client.so] Error 1 12:13:04: The process "/usr/bin/make" exited with code 2. Error while building/deploying project sozius-client (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.8.0)) When executing step "Make" 12:13:04: Elapsed time: 02:52.
My questions are:
- what architecture/configuration does qwt need? I have several of them on my machine
/home/staff/Qt5.8.0/5.8/android_armv7/lib/libqwt.so.6.1.2: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=131bd147d36585511f96ccd14ba1ccdd88c327cc, stripped
/media/qt5-qwt6/lib/libqwt.so.6.1.2: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=131bd147d36585511f96ccd14ba1ccdd88c327cc, stripped
/media/qt5-qwt6/qwt_android/qwt-6.1.3/lib/libqwt.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
- why is -ldns_sd not found? The dynamic libraries are definitely installed. Is it because they are not static libraries like the ones for protobuf?
/usr/lib64/libdns_sd.so /usr/lib64/libdns_sd.so.1 /usr/lib64/libdns_sd.so.1.0.0
Thank you for your patience with me
-
@a_so You need ARM build of libqwt (same as protobuf) as you're going to use it on an ARM processor, right?
Fix your pro file:LIBS += -L/media/qt5-qwt6/qwt_android/qwt-6.1.3/lib -lqwt INCLUDEPATH += /media/qt5-qwt6/qwt_android/qwt-6.1.3/include
Are those directories on your host machine?
/usr/lib64/libdns_sd.so /usr/lib64/libdns_sd.so.1 /usr/lib64/libdns_sd.so.1.0.0
If so, then please keep in mind that you cannot use them on your target (again: your target is ARM). You need libdns_sd.so in your sysroot. Is it there?
-
I edited the .pro file as you suggested, but I get the warning
:-1: warning: skipping incompatible /home/staff/Qt5.8.0/5.8/android_armv7/lib/libqwt.so while searching for qwt
The warning appears, yet I do not see any associated errors with qwt. I guess, this warning is implemented somewhere in the project and appears. But of course I used the paths you suggested. I should not worry too much about this warning, right?
The directories are on my host machine on which I run my qt. What do you mean by sysroot?
-
Yes. I found the problem for this. I copied the library files in there once and as the content in this path is loaded when I try to build the project, this warning gets displayed. My errors now are all linked to libdns from avahi.
/media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldns_sd ../sozius-client/so_bonjourservicebrowser.cpp:57: error: undefined reference to 'DNSServiceRefDeallocate' ../sozius-client/so_bonjourservicebrowser.cpp:92: error: undefined reference to 'DNSServiceBrowse' ../sozius-client/so_bonjourservicebrowser.cpp:103: error: undefined reference to 'DNSServiceRefSockFD' ../sozius-client/so_bonjourservicebrowser.cpp:138: error: undefined reference to 'DNSServiceProcessResult' ../sozius-client/so_bonjourserviceresolver.cpp:79: error: undefined reference to 'DNSServiceRefDeallocate' ../sozius-client/so_bonjourserviceresolver.cpp:121: error: undefined reference to 'DNSServiceResolve' ../sozius-client/so_bonjourserviceresolver.cpp:132: error: undefined reference to 'DNSServiceRefSockFD' ../sozius-client/so_bonjourserviceresolver.cpp:169: error: undefined reference to 'DNSServiceProcessResult' ../sozius-client/so_bonjourservicereconfirmer.cpp:46: error: undefined reference to 'DNSServiceQueryRecord' ../sozius-client/so_bonjourservicereconfirmer.cpp:57: error: undefined reference to 'DNSServiceRefSockFD' ../sozius-client/so_bonjourservicereconfirmer.cpp:104: error: undefined reference to 'DNSServiceProcessResult' ../sozius-client/so_bonjourservicereconfirmer.cpp:122: error: undefined reference to 'DNSServiceConstructFullName' ../sozius-client/so_bonjourservicereconfirmer.cpp:140: error: undefined reference to 'DNSServiceRefDeallocate' ../sozius-client/so_bonjourservicereconfirmer.cpp:161: error: undefined reference to 'DNSServiceReconfirmRecord' ../sozius-client/so_bonjourservicequeryrecord.cpp:84: error: undefined reference to 'DNSServiceQueryRecord' ../sozius-client/so_bonjourservicequeryrecord.cpp:99: error: undefined reference to 'DNSServiceRefSockFD' ../sozius-client/so_bonjourservicequeryrecord.cpp:133: error: undefined reference to 'DNSServiceProcessResult' ../sozius-client/so_bonjourservicequeryrecord.cpp:145: error: undefined reference to 'DNSServiceRefDeallocate' ../sozius-client/so_bonjourservice.cpp:43: error: undefined reference to 'TXTRecordGetCount' ../sozius-client/so_bonjourservice.cpp:47: error: undefined reference to 'TXTRecordGetItemAtIndex' ../sozius-client/so_bonjourservice.cpp:229: error: undefined reference to 'DNSServiceConstructFullName' collect2: error: ld returned 1 exit status make: *** [../build/Linux/debug/libsozius-client.so] Error 1 10:40:03: The process "/usr/bin/make" exited with code 2. Error while building/deploying project sozius-client (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.8.0)) When executing step "Make" 10:40:03: Elapsed time: 00:01.
My sysroot for ndk is
export NDK=/media/qt5-qwt6/ndk10/android-ndk-r10e export SYSROOT=$NDK/platforms/android-21/arch-arm
-
it is in:
/usr/lib64
But this is a x86_64 version for my linux host system. I want to build my shared library libdns_sd.so for arm architecture, but was not successful as a file is missing according to the link:
http://gaiger-programming.blogspot.co.at/2015/12/utilize-avahi-libraries-in-android-for.html
I have already contacted avahi but have not received a reply yet.