Using hiredis (redis client library)

8.6k views Asked by At

I have the redis server installed, and can use it from the command line. Now, I am wanting to write a client program using hiredis. To begin with, I tried to compile example.c which is present in the hiredis directory:

vishal@expmach:~/redis-2.6.14/deps/hiredis$ ls

adapters  async.h       COPYING  dict.h        *example.c*        example-libevent.c      
hiredis.c  Makefile  net.h      sds.c  test.c async.c   CHANGELOG.md  dict.c   example-
ae.c  example-libev.c  fmacros.h           hiredis.h  net.c     README.md  sds.h

Here are the commands:

vishal@expmach:~/redis-2.6.14/deps/hiredis$ gcc -c -I hiredis example.c
vishal@expmach:~/redis-2.6.14/deps/hiredis$ gcc -o example -I hiredis -L hiredis -lhiredis -lm

/usr/bin/ld: cannot find -lhiredis collect2: ld returned 1 exit status

I am not sure how to go about fixing this. Please help.

2

There are 2 answers

0
Gustavo Grisales On
gcc -o example example.c -lhiredis $(pkg-config --cflags --libs glib-2.0)
5
user1151446 On

why don't you juste juste the provided Makefile?

make

./hiredis-example