sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.64k stars 351 forks source link

[QUESTION] undefined refference ‘sw::redis::SimpleSentinel::SimpleSentinel(std::shared_ptr<sw::redis::Sentinel> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sw::redis::Role) #357

Closed runner66 closed 2 years ago

runner66 commented 2 years ago

I'm using Redis by Sentinel Mode in static library, but get some error when compile my code in Linux os(in win os, no error). If I try to use Single Mode, no error come out. Is there any tips?

Single Mode like this: "new Redis(connection_options, pool_options)" compile noerror Sentinel Mode like this: "new Redis(sentinel, "mymaster", Role::MASTER, connection_opts, pool_opts)" compile error

sewenew commented 2 years ago

Sorry but I cannot reproduce the problem on MacOS and Linux (ubuntu gcc10)

You can try to reinstall redis-plus-plus, i.e. remove the installed headers and libs, and install it again. Also ensure that you install one and only one version of hiredis and redis-plus-plus. If you still have the problem, please give a minimum code example that can reproduce the problem.

Also please check if you linked redis-plus-plus and hiredis correctly. For example:

g++ -std=c++17 -I/path/to/installation/of/redis-plus-plus/and/hiredis -o test test.app /path/to/libredis++.a /path/to/libhiredis.a -pthread

Regards

runner66 commented 2 years ago

Finally, I find the reason after several days... I compile redis-plus-plus with cmake, without setting gcc path.It seems that cmake use different gcc with my own code. After setting cmake gcc path, no error come out. A little weard, why single mode no error...

sewenew commented 2 years ago

Yes, it's strange. Not sure if you installed some old version redis-plus-plus which does not support sentinel, and when you didn't set gcc path, it linked to the wrong version of redis-plus-plus lib.

Regards