compile avahi to generate shared libraries for Android



  • Hello, I would like to deploy my Qt 5.8 application to my Android phone (android-21). During step make I get the error messages below. The project uses Avahi for mDNS services. I guess this can be resolved by building avahi for arm architecture.

    /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
    16:38:47: 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"
    16:38:47: Elapsed time: 00:06.
    

    What I have tried so far is in accordance to this link:
    Utilize Avahi Libraries in Android for mDNS Discovering

    configure step:

    ./configure --prefix=/home/staff/Desktop/avahi_compile --sysconfdir=/home/staff/Desktop/avahi_compile/etc --localstatedir=/home/staff/Desktop/avahi_compile/var --disable-static --disable-mono --disable-monodoc  --disable-gdbm --enable-libdaemon --disable-nls --disable-gtk --disable-gtk3 --disable-python --disable-qt3 --disable-qt4 --enable-core-docs --with-distro=none --enable-compat-libdns_sd --build=x86_64-pc-linux-gnu --host=arm-linux-androideabi --target=arm-linux-androideabi CC=/media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc CXX=/media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ LD=/media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
    

    config.log output:

    configure:4056: checking whether the C compiler works
    configure:4078: /media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc    conftest.c  >&5
    /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 open crtbegin_dynamic.o: No such file or directory
    /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 open crtend_android.o: No such file or directory
    /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 -lc
    /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 -ldl
    collect2: error: ld returned 1 exit status
    configure:4082: $? = 1
    configure:4120: result: no
    

    Could anyone explain me the bigger picture here? Where should these files be located?


  • Lifetime Qt Champion

    Hi,

    Not really Qt related but from a quick search if found this.

    Hope it helps



  • Thanks a lot! The error is gone.

    What I did was set environment variables :

    PATH=$PATH:/media/qt5-qwt6/tools25/tools
    PATH=$PATH:/media/qt5-qwt6/tools25/platform-tools
    PATH=$PATH:/media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
    export LD=arm-linux-androideabi-ld
    export CPP=arm-linux-androideabi-cpp
    export CC=arm-linux-androideabi-gcc
    export CXX=arm-linux-androideabi-g++
    export AS=arm-linux-androideabi-as
    export AR=arm-linux-androideabi-ar
    export RANLIB=arm-linux-androideabi-ranlib
    export ANDROID_SYSROOT=/media/qt5-qwt6/ndk10/android-ndk-r10e/platforms/android-4/arch-arm
    export CPPFLAGS="--sysroot=$ANDROID_SYSROOT"
    export CFLAGS="--sysroot=$ANDROID_SYSROOT"
    export CXXFLAGS="--sysroot=$ANDROID_SYSROOT"
    

    And this is my configure command:

    ./configure --prefix=/home/staff/Desktop/avahi_compile --sysconfdir=/home/staff/Desktop/avahi_compile/etc --localstatedir=/home/staff/Desktop/avahi_compile/var --disable-static --disable-mono --disable-monodoc  --disable-gdbm --enable-libdaemon --disable-nls --disable-gtk --disable-gtk3 --disable-python --disable-qt3 --disable-qt4 --enable-core-docs --with-distro=none --enable-compat-libdns_sd --build=x86_64-pc-linux-gnu --host=arm-linux-androideabi --target=arm-linux-androideabi --with-sysroot=/media/qt5-qwt6/ndk10/android-ndk-r10e/platforms/android-4/arch-arm --with-xml=expat
    


  • Yet now I face the next problem:

    configure: error: *** libexpat requested, but not found ***
    
    

    Expat header, source files and shared libraries are definitely installed on my linux system but it is x86_64 architecture and not arm.
    What I do is try to compile expat 2.2.0 for arm but I was not successful yet.

    This is what I did for expat compiling:

    PATH=$PATH:/media/qt5-qwt6/tools25/tools
    PATH=$PATH:/media/qt5-qwt6/tools25/platform-tools
    PATH=$PATH:/media/qt5-qwt6/ndk10/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
    export LD=arm-linux-androideabi-ld
    export CPP=arm-linux-androideabi-cpp
    export CC=arm-linux-androideabi-gcc
    export CXX=arm-linux-androideabi-g++
    export AS=arm-linux-androideabi-as
    export AR=arm-linux-androideabi-ar
    export RANLIB=arm-linux-androideabi-ranlib
    export ANDROID_SYSROOT=/media/qt5-qwt6/ndk10/android-ndk-r10e/platforms/android-4/arch-arm
    export CPPFLAGS="--sysroot=$ANDROID_SYSROOT"
    export CFLAGS="--sysroot=$ANDROID_SYSROOT"
    export CXXFLAGS="--sysroot=$ANDROID_SYSROOT"
    

    configure step:

    ./configure --prefix=/home/staff/Desktop/expat_built --enable-shared --build=x86_64-pc-linux-gnu --host=arm-linux-androideabi --with-sysroot=/media/qt5-qwt6/ndk10/android-ndk-r10e/platforms/android-4/arch-arm
    

    My arm-linux-androideabi-gcc compiler from Android NDK works and it says we are cross-compiling.
    But as given in config.log, file ac_nonexistent.h is not found.

    configure:7029: checking how to run the C preprocessor
    configure:7099: result: arm-linux-androideabi-cpp
    configure:7119: arm-linux-androideabi-cpp --sysroot=/media/qt5-qwt6/ndk10/android-ndk-r10e/platforms/android-4/arch-arm conftest.c
    configure:7119: $? = 0
    configure:7133: arm-linux-androideabi-cpp --sysroot=/media/qt5-qwt6/ndk10/android-ndk-r10e/platforms/android-4/arch-arm conftest.c
    conftest.c:9:28: fatal error: ac_nonexistent.h: No such file or directory
     #include <ac_nonexistent.h>
                                ^
    compilation terminated.
    configure:7133: $? = 1
    configure: failed program was:
    | /* confdefs.h */
    | #define PACKAGE_NAME "expat"
    | #define PACKAGE_TARNAME "expat"
    | #define PACKAGE_VERSION "2.2.0"
    | #define PACKAGE_STRING "expat 2.2.0"
    | #define PACKAGE_BUGREPORT "expat-bugs@libexpat.org"
    | #define PACKAGE_URL ""
    | /* end confdefs.h.  */
    | #include <ac_nonexistent.h>
    

    Where should it be located? Is it another linking problem? Thank you for your help!


  • Moderators

    @a_so said in compile avahi to generate shared libraries for Android:

    Expat

    You should ask Expat maintainers/developers.



  • @jsulm thank you, I already know what the problem is! The error is supposed to occur due to a test case where header file includes are checked.


  • Moderators

    @a_so Yes, it should actually not fail. It is most probably an issue with Expat.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.