ZooKeeper C binding installation

2019-08-20 03:22发布

问题:

I am trying to install the C binding for ZooKeeper while ssh'ed to another computer using a build system: i386-pc-solaris2.11 (I don't know if that is important). Anyways, the computer I ssh'ed to is running a linux based OS.

I ran the following code in the command line:

cd ../zookeeper
cd src
cd c
./configure
make

The terminal inputs above were taken from the Apache website for setting up the C shell client. The error code I am getting is originates from the make:

libtool: link: ( cd ".libs" && rm -f "libzookeeper_mt.la" && ln -s 
"../libzookeeper_mt.la" "libzookeeper_mt.la" )
gcc -DHAVE_CONFIG_H -I.  -I./include -I./tests -I./generated -
D_POSIX_PTHREAD_SEMANTICS  -Wall -Werror -g -O2 -D_GNU_SOURCE -MT cli.o 
-MD -MP -MF .deps/cli.Tpo -c -o cli.o `test -f 'src/cli.c' || echo 
'./'`src/cli.c
mv -f .deps/cli.Tpo .deps/cli.Po
/bin/sh ./libtool  --tag=CC    --mode=link gcc -Wall -Werror -g -O2 -
D_GNU_SOURCE    -o cli_st cli.o libzookeeper_st.la 
libtool: link: gcc -Wall -Werror -g -O2 -D_GNU_SOURCE -o .libs/cli_st 
cli.o  ./.libs/libzookeeper_st.so -lnsl -lsocket -lm -R/usr/local/lib
gcc -DHAVE_CONFIG_H -I.  -I./include -I./tests -I./generated -
D_POSIX_PTHREAD_SEMANTICS  -DTHREADED -g -O2 -D_GNU_SOURCE -MT cli_mt-
cli.o -MD -MP -MF .deps/cli_mt-cli.Tpo -c -o cli_mt-cli.o `test -f 
'src/cli.c' || echo './'`src/cli.c
mv -f .deps/cli_mt-cli.Tpo .deps/cli_mt-cli.Po
/bin/sh ./libtool  --tag=CC    --mode=link gcc -DTHREADED -g -O2 -
D_GNU_SOURCE    -o cli_mt cli_mt-cli.o libzookeeper_mt.la 
libtool: link: gcc -DTHREADED -g -O2 -D_GNU_SOURCE -o .libs/cli_mt 
cli_mt-cli.o  ./.libs/libzookeeper_mt.so -lnsl -lsocket -lm -lpthread -
R/usr/local/lib
Undefined                       first referenced
 symbol                             in file
__ .sync_fetch_and_add                ./.libs/libzookeeper_mt.so
ld: fatal: symbol referencing errors. No output written to .libs/cli_mt
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `cli_mt'
Current working directory 
/workspace/kunalp/mysource/usr/src/kunalp/zookeeperC2/src/c
*** Error code 1
make: Fatal error: Command failed for target `all'

cli_mt:localhost:2181 does not work as the ZooKeeper library is not installed in /usr/local/lib . I do however have zookeeper working in the C client on my local computer, I just need it working on this system.

Please help, this is just the installation of zookeeper on a linux computer. I don't understand linux too well, nor do I understand the error code given to me from this makefile.

EDIT: I figured out that I do not have permissions to change the /usrs/local/lib directory on this server. I tried

distclean && ./configure --prefix=/workspace/kunalp/zookeeper/ --libdir=/workspace/kunalp/zookeeper/lib && make install

to relocate the library directory. This however did not fix the problem, giving me the following error:

/bin/sh ./libtool  --tag=CC    --mode=link gcc -DTHREADED -g -O2 -
D_GNU_SOURCE    -o cli_mt cli_mt-cli.o libzookeeper_mt.la 
libtool: link: gcc -DTHREADED -g -O2 -D_GNU_SOURCE -o .libs/cli_mt 
cli_mt-cli.o  ./.libs/libzookeeper_mt.so -lnsl -lsocket -lm -lpthread -
R/workspace/kunalp/zookeeper/lib
Undefined                       first referenced
symbol                             in file
 __sync_fetch_and_add                ./.libs/libzookeeper_mt.so
ld: fatal: symbol referencing errors. No output written to .libs/cli_mt
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `cli_mt'

Thanks

回答1:

The Solaris compiler does not have __sync_fetch_and_add. To fix this I had to find an equivalent function in the Solaris compailer: atomic_add() and replace __sync_fetch_and_add with atomic_add() in mt_adaptor.c. This fixed my make command