zeromq / zeromq3-x

ØMQ/3.2 release branch - bug fixes only

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Patch to make it Android friendly

cyrilh opened this issue · comments

Hi,

I have been working on porting pyzmq to Android (see work progress here: zeromq/pyzmq#227 (comment)). The symptoms without the patch are:

  • pyzmq copies libzmq.so.3 to it's own zmq/libzmq.so
  • running python "import zmq" will load that file a first time, but I suspect zmq/libzmq.so will dynamically link against libzmq.so.3 and try to open the non-existing file anyway.
  • a symlink from libzmq.so.3 to libzmq.so solves that problem but this is not clean IMHO
  • linking libzmq.so with -avoid-version on Android solves that problem, so I post the following patch

Starting from libzmq3.x (https://github.com/zeromq/zeromq3-x), the following patch that will add -avoid-version to LDFLAGS:

diff --git a/configure.in b/configure.in
index 7152015..60416ff 100644
--- a/configure.in
+++ b/configure.in
@@ -75,8 +75,9 @@ libzmq_werror="yes"
 # By default use DSO visibility
 libzmq_dso_visibility="yes"

-# Whether we are on mingw or not.
+# Whether we are on mingw or android or not.
 libzmq_on_mingw32="no"
+libzmq_on_android="no"

 # Set some default features required by 0MQ code.
 CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS"
@@ -96,6 +97,7 @@ case "${host_os}" in
         case "${host_os}" in
             *android*)
                 AC_DEFINE(ZMQ_HAVE_ANDROID, 1, [Have Android OS])
+                libzmq_on_android="yes"
             ;;
         esac
         ;;
@@ -373,6 +375,7 @@ AC_LANG_POP([C++])

 AM_CONDITIONAL(BUILD_PGM, test "x$libzmq_pgm_ext" = "xyes")
 AM_CONDITIONAL(ON_MINGW, test "x$libzmq_on_mingw32" = "xyes")
+AM_CONDITIONAL(ON_ANDROID, test "x$libzmq_on_android" = "xyes")

 # Checks for library functions.
 AC_TYPE_SIGNAL
diff --git a/src/Makefile.am b/src/Makefile.am
index c69a556..23c8cbe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -138,8 +138,12 @@ libzmq_la_SOURCES = \
 if ON_MINGW
 libzmq_la_LDFLAGS = -no-undefined -avoid-version -version-info @LTVER@ @LIBZMQ_EXTRA_LDFLAGS@
 else
+if ON_ANDROID
+libzmq_la_LDFLAGS = -avoid-version -version-info @LTVER@ @LIBZMQ_EXTRA_LDFLAGS@
+else
 libzmq_la_LDFLAGS = -version-info @LTVER@ @LIBZMQ_EXTRA_LDFLAGS@
 endif
+endif

 libzmq_la_CXXFLAGS = @LIBZMQ_EXTRA_CXXFLAGS@

Then I also need to make use of that patch not yet released in 3.x: zeromq/libzmq@eb6c668

I have never made git pull request and do not have any folder on git... I will try to keep it that way for now, that's why I post my patch here.

EDITS:

  • added defaulting "libzmq_on_android" to "no"
  • fixing page formatting
  • I hope those many edits do not generate many emails to a mailing list, if so please warn me.

OK... it was not so hard after all, see zeromq/libzmq#393