1

I want to compile the client for redis in C. I've downloaded and installed the libevent library and the hiredis files. I've used this command:

gcc -I/home/tasos/Dropbox/lists/hiredis example-libevent.c -levent

but I get these errors:

/tmp/ccxoerYJ.o: In function `redisLibeventReadEvent':
example-libevent.c:(.text+0x28): undefined reference to `redisAsyncHandleRead'
/tmp/ccxoerYJ.o: In function `redisLibeventWriteEvent':
example-libevent.c:(.text+0x56): undefined reference to `redisAsyncHandleWrite'
/tmp/ccxoerYJ.o: In function `getCallback':
example-libevent.c:(.text+0x2d2): undefined reference to `redisAsyncDisconnect'
/tmp/ccxoerYJ.o: In function `main':
example-libevent.c:(.text+0x393): undefined reference to `redisAsyncConnect'
example-libevent.c:(.text+0x3f3): undefined reference to `redisAsyncSetConnectCallback'
example-libevent.c:(.text+0x404): undefined reference to `redisAsyncSetDisconnectCallback'
example-libevent.c:(.text+0x45d): undefined reference to `redisAsyncCommand'
example-libevent.c:(.text+0x47d): undefined reference to `redisAsyncCommand'
collect2: ld returned 1 exit status

why isn't this working?

TasostheGreat
  • 432
  • 1
  • 9
  • 24

1 Answers1

5

Use -levent and -lhiredis compile option in command.

Jayesh Bhoi
  • 24,694
  • 15
  • 58
  • 73
  • 1
    I am trying the following >>> gcc -c redismake.c -levent -lhiredis -I'/home/ubuntu/workspace/c/hiredis' gcc redismake.o -o redismake <<< and I get this error: redismake.o: In function `main': redismake.c:(.text+0x22): undefined reference to `redisConnect' collect2: error: ld returned 1 exit status. Any thoughts ?! – Stefan Ciprian Hotoleanu Mar 17 '16 at 18:57