ZeroMQ error: unknown type name 'zctx_t

I am trying to follow the manual at this link: http://hintjens.com/blog:49 install ZeroMQ and run a simple example as follows:

#include <czmq.h>

int main (void) {
    zctx_t *ctx = zctx_new ();
    void *publisher = zsocket_new (ctx, ZMQ_PUB);
    zsocket_set_curve_server (publisher, true);
    puts ("Hello, Curve!");
    zctx_destroy (&ctx);
    return 0;
}

However, I received this error message:

hello.c: In function ‘main’:
hello.c:4:5: error: unknown type name ‘zctx_t’
     zctx_t *ctx = zctx_new ();
     ^
hello.c:4:19: warning: initialization makes pointer from integer without a cast [enabled by default]
     zctx_t *ctx = zctx_new ();
                   ^
hello.c:5:23: warning: initialization makes pointer from integer without a cast [enabled by default]
     void *publisher = zsocket_new (ctx, ZMQ_PUB);
                       ^

Could you help me? I am using Ubuntu 14, and ZeroMQ was successfully installed with these commands:

git clone git://github.com/jedisct1/libsodium.git
cd libsodium
./autogen.sh
./configure && make check
sudo make install
sudo ldconfig
cd ..

git clone git://github.com/zeromq/libzmq.git
cd libzmq
./autogen.sh
./configure && make check
sudo make install
sudo ldconfig
cd ..

git clone git://github.com/zeromq/czmq.git
cd czmq
./autogen.sh
./configure && make check
sudo make install
sudo ldconfig
cd ..
+4
source share
1 answer

This code uses the CZMQ API v2, which was DEPRECATED in v3 and REDACTED in v4 ( https://github.com/zeromq/czmq/releases/tag/v4.0.0 ). The equivalent code working with v4 would be:

#include <czmq.h>

int main (void) {
    zsock_t *publisher = zsock_new (ZMQ_PUB);
    zsock_set_curve_server (publisher, true);
    puts ("Hello, Curve!");
    zsock_destroy (&publisher);
    return 0;
}

https://github.com/zeromq/czmq/tree/master/examples/security.

+1

Source: https://habr.com/ru/post/1670142/


All Articles