zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pankaj Kumar <pankajku...@juniper.net.INVALID>
Subject Re: How to use -DTHREADED compile option while compiling
Date Wed, 10 Jun 2020 09:44:30 GMT
Thank you so much Damien and Szalay for helping out.
My issue got resolved by including THREADED and HAVE_OPENSSL_H in my compiler options. I am
able to call the API now.
I didn't know that. I thought we have to enable theses flags while building zookeeper C library.
Thank you Damien for this __ __

On 10/06/20, 1:57 PM, "Damien Diederen" <ddiederen@sinenomine.net> wrote:

    [External Email. Be cautious of content]


    Hello Pankaj,

    > Please help me in defining those ifdef THREADED and HAVE_OPENSSL_H variables.

    Once you have a ZooKeeper client library compiled with the required
    features (which is indeed easily obtained by doing a Maven build in an
    environment which provides the supporting libraries), it is just a
    matter of providing the definitions to the compiler (possibly via a
    build tool).

    If you have any doubts, this might help determining whether the
    sought-after code is present ("T") in the shared object:

        nm -D $ZOOKEEPER_PREFIX/lib/libzookeeper_mt.so | grep zookeeper_init_ssl
        000000000000c202 T zookeeper_init_ssl

    (Using 'readelf --dyn-syms' is an alternative.)


    Trivial example: a single-file 'zk-hello.c' program making use of the
    targeted API can be compiled using e.g.:

        gcc \
            -g -Wall \
            -I$ZOOKEEPER_PREFIX/include/zookeeper \
            -DTHREADED \
            -DHAVE_OPENSSL_H \
            -o zk-hello \
            zk-hello.c \
            -L$ZOOKEEPER_PREFIX/lib \
            -lzookeeper_mt

    (Note the '-DTHREADED' and '-DHAVE_OPENSSL_H' arguments, which allow the
    compiler to see the relevant API declarations.)

    Upon successul compilation, the executable contains an unresolved ("U")
    reference to the aforementioned function:

        nm zk-hello | grep zookeeper_init_ssl
                         U zookeeper_init_ssl


    Of course, you will have to adapt the instructions above to your build
    tool of choice, if any.  But that procedure is specific to the build
    tool, not ZooKeeper.

    Hope this helps, -D



    Pankaj Kumar <pankajkumar@juniper.net.INVALID> writes:
    > Hi Szalay,
    > I have tried the same as you mentioned, linked code against
    > zookeeper_mt library but still I am not able to call the API’s present
    > under #ifdef THREADED. When I comment this ifdef then I am able to
    > call the API’s. Getting the same error as mentioned below.
    > Also I have to use ssl support which is defined like this in zookeeper.h
    >
    > #ifdef HAVE_OPENSSL_H
    > ZOOAPI zhandle_t *zookeeper_init_ssl(const char *host, const char
    > *cert, watcher_fn fn,
    > int recv_timeout, const clientid_t *clientid, void *context, int flags);
    > #endif
    >
    > While building library with maven, it was mentioned that
    > -Dc-client-openssl has default value yes. But still I am not able to
    > call zookeeper_init_ssl API.
    > Looks like the API’s defined under ifdef I am not able to call that.
    > I am attaching zookeeper.spec which I use to make libzookeeper and
    > libzookeeper-devel libraries.
    > Please help me in defining those ifdef THREADED and HAVE_OPENSSL_H variables.
    >
    > Thanks.
    > Pankaj
    >
    >
    >
    >>Hello Pankaj,
    >
    >
    >
    >>ZooKeeper C client provides two different APIs, a sync (multithreaded) and
    >
    >>an async (single threaded).
    >
    >>If you want to use the sync API (multi threaded) then make sure to link
    >
    >>your application code against the zookeeper_mt library.
    >
    >
    >
    >>When compiling the ZooKeeper C client code, you can set if you want to also
    >
    >>build the zookeeper_mt library. Depending on your preferred build tool:
    >
    >>- cmake: use the -DTHREADED cmake option to enable sync API build
    >
    >>- make: use the "./configure --without-syncapi" to disable the sync API
    >
    >>build
    >
    >
    >
    >>normally I just use "mvn clean install -DskipTests -Pfull-build" command to
    >
    >>build both the java and C code, which will build both the sync and async
    >
    >>zookeeper libraries.
    >
    >
    >
    >>This readme file should help, although I am not 100% sure it is totally
    >
    >>up-to-date :)
    >
    >>https://github.com/apache/zookeeper/tree/master/zookeeper-client/zookeeper-client-c
    >
    >
    >
    >>Kind regards,
    >
    >>Mate
    >
    > From: Pankaj Kumar <pankajkumar@juniper.net>
    > Date: Friday, 5 June 2020 at 5:19 PM
    > To: "user@zookeeper.apache.org" <user@zookeeper.apache.org>
    > Subject: How to use -DTHREADED compile option while compiling
    >
    > Hi,
    > I was making libzookeeper and libzookeeper-devel for latest zookeeper release 3.6.1.
    > In our software we are making some api calls, however some api calls are giving error:-
    >
    >
    > error: ‘zoo_create’ was not declared in this scope
    >
    >              path_buffer_len);
    >
    >                             ^
    >
    > error: ‘zoo_delete’ was not declared in this scope
    >
    >          return zoo_delete(zh, path, version);
    >
    >
    >
    > error: ‘zoo_get’ was not declared in this scope
    >
    >          return zoo_get(zh, path, watch, buffer, buffer_len, stat);
    >
    >                                                                  ^
    >
    > error: ‘zoo_exists’ was not declared in this scope
    >
    >
    >
    >
    >
    > Then after looking into latest library code and found that these calls are defined
under #define THREADED
    > And for this thing to work I have to compile zookeeper C client with -DTHREADED option.
    >
    > What I want to ask that How can I enable this compile -DTHREADED option. I have tried
this with “make” command and “./configure” command, but couldn’t proceed further.
    >
    > Can someone please help me on how to use DTHREADED option?
    >
    > Thanks,
    > Pankaj
    >
    >
    > Juniper Business Use Only


Juniper Business Use Only
Mime
View raw message