[zeromq-dev] Issue linking ZMQ static library into shared library for Android

Matthias Brzezinski Matthias.Brzezinski at gmx.de
Sun Mar 8 00:11:49 CET 2015

actually I had some time trying out if the library works and I was wrong 
- it does not work. The library throws many undefined reference errors 
when I'm not using LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
In the case I'm using it, my program will crash on startup with the error
"cannot locate symbol 
I'm just loading both static libraries - sodium and zmq - into my 
project like I normally do with libraries.

Probably someone has another Idea why zeromq does not work with the NDK.

With Regards,

Am 06.03.2015 um 19:25 schrieb Matthias Brzezinski:
> Hey Joe,
> thank you for your answer.
> I've looked through your script and it helped me verifying that I did 
> not miss a flag, a step or something i was not considering yet.
> Generally it doesn't matter if I compile a static or a shared library 
> - The NDK uses its own linker to link the prebuilt libraries.
> Am 06.03.2015 um 18:17 schrieb Joe McIlvain:
>> Matthias,
>> I don't usually compile them as static, but you may be able to get 
>> some ideas/help from using or looking at the scripts I added under 
>> `builds/qt-android`of the zeromq repository.  I use these to compile 
>> for use with Qt on android, but there's nothing really Qt-specific 
>> about them.  I only added them because the android scripts didn't 
>> work for me.  They didn't seem to be
> The syntax for the android makefiles are a bit different, but I used 
> the same flags as far I can see. Hence, I never worked with qt before.
> What exactly didn't work with the android scripts? Did you have 
> problems getting the NDK to work generally, or just the NDK in 
> combination with ZeroMQ? I hope for the first, because it would be a 
> mess if I wouldn't find a way to use ZeroMQ with native code and the 
> NDK where for example the protobuf library compiled on the first try.
> With regards,
> Matthias
>> maintained, but I didn't want to clobber something that someone out 
>> there might be relying on.
>> I don't know a lot about the android toolchain because working with 
>> Qt hides a lot of the platform-specific stuff from me, but I learned 
>> just enough about the toolchain to make those scripts work and get 
>> them into the CI for the repository.
>> On Fri, Mar 6, 2015 at 6:30 AM, Matthias Brzezinski 
>> <Matthias.Brzezinski at gmx.de <mailto:Matthias.Brzezinski at gmx.de>> wrote:
>>     Hey,
>>     I'm having issues linking ZeroMQ into my shared library for Android.
>>     I followed the steps on http://zeromq.org/build:android to build
>>     the static library. I tried it with the recommended NDKr8 but
>>     also tried it with the NDK10d. I've build the static library for
>>     arm with the official ndk-toolchain.
>>     Afterwards I try to link thoose libraries into my shared library
>>     to compile a bunch of cpp files.
>>     I've successfully compiled and linked different static libraries
>>     into my projects so I'm pretty confused why the linker throws the
>>     Error when I work with ZeroMQ. I've omitted the other working
>>     libraries.
>>     My Android.mk:
>>     http://pastebin.com/N7gueqre
>>     My Application.mk:
>>     http://pastebin.com/nNgCYM2F
>>     In both code blocks I've ommited everything that is not necessary
>>     for solving this issue. The error message stays the same. I've
>>     tried to build the shared library under windows and later under
>>     debian and ubuntu. The error message is:
>>     /tmp/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld:
>>     error: ./zmq/lib    /libzmq.a(libzmq_la-zmq.o): incompatible target
>>         collect2: error: ld returned 1 exit status
>>         make: *** [obj/local/armeabi/libzmqTest.so] Error 1
>>     (I guess 3 lines are not worth a pastebin)
>>     I'm working on Windows 8.1 with Android Studio 1.1. I've compiled
>>     the libraries under Linux Mint 16, a up-to-date ubuntu system and
>>     an old debian server.
>>     I build zeromq3-x and zeromq4-x.
>>     Any idea is welcome and appreciated.
>>     If this is not the right place to ask such a question, please
>>     tell me where to ask it instead.
>>     With regards,
>>     Matthias
>>     _______________________________________________
>>     zeromq-dev mailing list
>>     zeromq-dev at lists.zeromq.org <mailto:zeromq-dev at lists.zeromq.org>
>>     http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150308/0f2f82f6/attachment.htm>

More information about the zeromq-dev mailing list