ipfixcol2
ipfixcol2 copied to clipboard
using hiredis in output plugin
Hi, I want to change Printer.cpp in json output plugins to use redis, in order to use hiredis -lhiredis flag should be added to compiler options, Unfortunately I'am a newbie in c/c++, so I don't know how to include this flag so the compiler recognize hiredis library.
My changes to Printer.cpp so far:
#include <hiredis/hiredis.h>
redisContext *c;
redisReply *reply;
c = redisConnect("127.0.0.1", 6379);
reply = (redisReply *)redisCommand(c, "PING");
printf("REDIS PING: %s\n", reply->str);
freeReplyObject(reply);
Thanks.
Hi,
the easiest (and also the most naïve) way is to modify target_link_libraries
command in CMakeLists.txt file of the JSON plugin:
target_link_libraries(json-output
${ZLIB_LIBRARIES}
${LIBRDKAFKA_LIBRARIES}
hiredis # <<< new parameter
)
Slightly better way is to use add following lines at the beginning of the file:
find_package(PkgConfig REQUIRED)
pkg_check_modules(HIREDIS REQUIRED hiredis)
and modify commands:
include_directories(
${ZLIB_INCLUDE_DIRS} # zlib
${LIBRDKAFKA_INCLUDE_DIRS} # librdkafka
${HIREDIS_INCLUDE_DIRS} # <<< new parameter
)
target_link_libraries(json-output
${ZLIB_LIBRARIES}
${LIBRDKAFKA_LIBRARIES}
${HIREDIS_LIBRARIES} # <<< new parameter
)
Lukas