Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using hiredis in output plugin #66

Open
kama1 opened this issue Apr 30, 2022 · 1 comment
Open

using hiredis in output plugin #66

kama1 opened this issue Apr 30, 2022 · 1 comment

Comments

@kama1
Copy link

kama1 commented Apr 30, 2022

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.

@Lukas955
Copy link
Collaborator

Lukas955 commented May 2, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants