Undefined Symbol on redis.subscriber()
thomasmurphycodes opened this issue · 4 comments
The issue is that I am able to run redis.get() and redis.set(), but compilation fails if I try to create a subscriber() object. I am following the CMake example provided in the README. Are there additional symbols to be linked to make subscriber() able to be compiled?
Minimal reproduceable example:
#define CPPHTTPLIB_OPENSSL_SUPPORT
#include <sw/redis++/redis++.h>
using namespace sw::redis;
// Create an Redis object, which is movable but NOT copyable.
Redis redis = Redis("tcp://127.0.0.1:6379");
int main() {
auto sub = redis.subscriber();
return 0;
}
Compilation error:
Undefined symbols for architecture arm64:
"_redisFree", referenced from:
sw::redis::Connection::ContextDeleter::operator()(redisContext*) const in main.cpp.o
Platform: Mac OSX 12.3.1
Compilation command: /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/thomasmurphy/CLionProjects/remote_build_test/cmake-build-debug --target remote_build_test -- -j 6
Sorry but I cannot reproduce your problem.
However, I'm not sure if the macro CPPHTTPLIB_OPENSSL_SUPPORT
you defined, e.g. other libs included, has any impact on it. Could you please remove other dependencies, and retry it?
Regards
Also, please ensure that you linked with libhiredis.a or libhiredis.so. _redisFree
is defined by hiredis, and your error message shows that the related symbols is not defined. Normally, you can fix this problem by linking libhiredis.
Regards
I will try to get a repro going in isolation reflecting comments above in next couple of days - thanks!
Since there's no update, I'll close this issue.
Regards