I have a problem that I can’t solve without any help:
After I tried some test programs with the WP7102 I wanted to use ZeroMQ as a message broker for my future programs.
So I installed the library on my host and on my target and the “hello world” sample from ZeroMQ works on the target as well as on the host, so I think I installed the libraries correctly.
Now I wanted to write this “hello world” sample from ZeroMQ in Legato and the only thing I changed is I used LE_INFO instead of printf and COMPONENT_INIT instead of int main (void).
But there always appears the same error:
root@swi-mdm9x15:~# app start zmq
Starting app ‘zmq’…
myServer: error while loading shared libraries: libzmq.so.4: cannot open shared object file: No such file or directory
myClient: error while loading shared libraries: libzmq.so.4: cannot open shared object file: No such file or directory
root@swi-mdm9x15:~# app status
Here is the logread from the “app start zmq” command: recording app start logread.txt (8.63 KB)
In the .adef file I included the library in the “bundles” section like the following:
[r] libzmq.so.4.0.0 /lib
And in the .cdef files like the following:
When I try to execute only the client or only the server in the .adef file, it doesn’t work, too.
Also here is what comes when I type the “make wp7” command and what I get when I run the “instapp” command: recording make wp7.txt (6.62 KB)
recording instapp.txt (10.9 KB)
I hope you can help me
And here is my app:
zmqTest.zip (1000 KB)
It looks like your program is trying to open libzmq.so.4, but the library appears in your application’s sandbox as libzmq.so.4.0.0.
If you change the bundles section to this, it should work:
[r] libzmq.so.4.0.0 /lib/libzmq.so.4
Note that because your COMPONENT_INIT functions never return, your program will never be able to process any other events. In your trivial sample app, this is not a problem, but if you want to start using asynchronous notification features of some APIs (such as the le_data API’s notification when your cellular data connection comes up or goes down), you’ll need to either spawn another thread or find a way to return from your COMPONENT_INIT.
Obviously, if you go multi-threaded, then you have to worry about races between threads, etc.
Fortunately, 0MQ provides a mechanism for integrating with other event loops, and that works with ours too.
The function zmq_getsockopt() can be used to fetch the file descriptor associated with the 0MQ socket (option ZMQ_FD). This can then be monitored for “readability” using a Legato “file descriptor monitor” (legato.io/legato-docs/14_10/ … vent_files).
After you have created a file descriptor monitor and set your “readability” handler function, when a message arrives on your 0MQ socket, your handler function will be called. You should move your while loop into that handler function. But, remember to make sure that loop doesn’t block, or you’ll just be stopping your event loop there instead of in your COMPONENT_INIT. You can do a non-blocking zmq_recv() (using the ZMQ_DONTWAIT option flag) and return from your handler function if zmq_recv() reports that there’s nothing to receive.
I hope this helps!
Thanks a lot for your help!