zeromq / zeromq4-x

ØMQ 4.x stable release branch - bug fixes only
GNU General Public License v3.0
458 stars 196 forks source link

Compile errors when use libzmq IOS pod #162

Closed cybermag closed 7 years ago

cybermag commented 7 years ago

Hello All!

I would like to use libzmq pod for my IOS project.

def myPods pod 'libsodium' pod 'libzmq' end

My Xcode version is 8.3.1.

I have faced with the following issues:

  1. My project is not compiled because the platform.hpp file is missed. I have resolved such issue by creation of such file with the following defines:

ifndef platform_h

define platform_h

define ZMQ_FORCE_SELECT

define ZMQ_HAVE_UIO

endif / platform_h /

  1. The second issue is that the project still is not compiled due the following error:

Pods/libzmq/src/select.cpp:166:13: Non-constant-expression cannot be narrowed from type 'long' to '__darwin_suseconds_t' (aka 'int') in initializer list

I have fixed the issue using explicit cast :

    struct timeval tv = {(long) (timeout / 1000),
        static_cast<__darwin_suseconds_t>((long) (timeout % 1000 * 1000))};

After that the project has built correctly. I have tried a couple of tests from zmq and it seems that they work correctly.

I have two options:

  1. I can create pull requests for such fixes to zmq repository if you will include them into sources.
  2. I can fix such problems by myself, then fork from zmq stable branch 4.0.4, create some other repository and to merge my fixes to forked branch.

Could you please advice the direction of solving such problem?

cybermag commented 7 years ago

BTW, it's even better to fix the compile error in following cross-platform way:

original code from select.cpp, function void zmq::select_t::loop ()

    int timeout = (int) execute_timers ();

    //  Intialise the pollsets.
    memcpy (&readfds, &source_set_in, sizeof source_set_in);
    memcpy (&writefds, &source_set_out, sizeof source_set_out);
    memcpy (&exceptfds, &source_set_err, sizeof source_set_err);

    //  Wait for events.
    struct timeval tv = {(long) (timeout / 1000),
        (long) (timeout % 1000 * 1000)};

the fixed code:

    struct timeval tv = {(int) (timeout / 1000),
                                     (int) (timeout % 1000 * 1000)};
bluca commented 7 years ago

The select problem was already fixed in 4.1.x and 4.2.x by https://github.com/zeromq/libzmq/pull/1181 feel free to cherry-pick the patch (please use git format-patch and git am to track the original author) and do a PR to this repository if you need it in 4.0.x. Also please add an entry in the NEWS file if you do so.

The platform.hpp is generated at build time by autoconf/cmake/etc, not a Mac user so I'm not sure how to integrate autoconf/cmake in Xcode but there must be documentation by Apple

cybermag commented 7 years ago

Sorry, are the any way to add latest version (4.2.2) of libzmq to cocoa pods? It seems that it is needed just to update the podspec? Can I do that by myself?

bluca commented 7 years ago

I'm sorry but I'm not an OSX user/dev so no idea - if you can't find out, try asking on the mailing list http://zeromq.org/docs:mailing-lists or on IRC http://zeromq.org/chatroom

cybermag commented 7 years ago

Thanks! I will ask community for the help.