[zeromq-dev] my first experience in mixing zmq1 and zmq2 in one app

Pavel Gushcha pavimus at gmail.com
Wed Dec 23 12:37:49 CET 2009


I am developing system, that contains many programs, that are connected by
яmq. Development was started in zmq1 and is too difficult stop development
and port all programs to clean zmq2. So i decided do it step by step. Now i
don't want (and don't tested yet) send messages to/from zmq1
exchanges/queues to zmq2 sockets. if my old app1 uses separate code talk
with app2, i want to port these parts of app1 and app2 from zmq1 to zmq2. In
this scenario i must mix zmq1 and zmq2 code in one application. For doing
this, some zmq modifications are needed:

first we must rename namespace zmq to zmq2 in zmq2 sources. Without this,
all compiles successfully, but overlapping of functions in so files
producess strange errors and segmentation faults.

For renaming i executed following code in directory with zmq2 sources before
make:
        find . -name "*.h" | xargs -I % sh modify.sh %
        find . -name "*.c" | xargs -I % sh modify.sh %
        find . -name "*.hpp" | xargs -I % sh modify.sh %
        find . -name "*.cpp" | xargs -I % sh modify.sh %
where modify.sh is:
sed 's/zmq::/zmq2::/g;s/namespace zmq/namespace zmq2/g' $1 >$1.tmp && mv
$1.tmp $1

now we can run make & make install

Additionally we need to rename:
1) compiled so to something like libzmq2.so instead libzmq.
2) bindings zmq.h to zmq2.h, zmq.hpp to zmq2.hpp. And in zmq2.hpp we need
change #include "zmq.h" to #include "zmq2.h"

i attached dirty gentoo ebuild for zmq1 and zmq2.

May be this info will be helpful for somebody.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20091223/fb27f3b0/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zmq-1.9999.ebuild
Type: application/octet-stream
Size: 412 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20091223/fb27f3b0/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zmq-2.9999.ebuild
Type: application/octet-stream
Size: 1254 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20091223/fb27f3b0/attachment-0001.obj>


More information about the zeromq-dev mailing list