Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile errors when use libzmq IOS pod #162

Closed
cybermag opened this issue Apr 14, 2017 · 5 comments
Closed

Compile errors when use libzmq IOS pod #162

cybermag opened this issue Apr 14, 2017 · 5 comments

Comments

@cybermag
Copy link

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
Copy link
Author

cybermag commented Apr 14, 2017

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
Copy link
Member

bluca commented Apr 14, 2017

The select problem was already fixed in 4.1.x and 4.2.x by zeromq/libzmq#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
Copy link
Author

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
Copy link
Member

bluca commented Apr 14, 2017

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
Copy link
Author

Thanks! I will ask community for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants