Issues building redis-plus-plus along with test (and using it)

596 views
Skip to first unread message

Maham M. Firdous

unread,
Mar 11, 2021, 8:46:01 AM3/11/21
to Redis DB
Good Day,
Please take a look at the following log. I installed redis from source using the latest github repository clone and the prefix in my hiredis makefile was set to usr/local. I did not change it. I am getting the following errors.
Scanning dependencies of target test_redis++
[ 83%] Building CXX object test/CMakeFiles/test_redis++.dir/src/sw/redis++/test_main.cpp.o
[ 97%] Built target redis-plus-plus-shared
[100%] Linking CXX executable test_redis++
/usr/bin/ld: CMakeFiles/test_redis++.dir/src/sw/redis++/test_main.cpp.o: in function `std::_Sp_counted_ptr_inplace<sw::redis::ConnectionPool, std::allocator<sw::redis::ConnectionPool>, (__gnu_cxx::_Lock_policy)2>::_M_dispose()':
test_main.cpp:(.text._ZNSt23_Sp_counted_ptr_inplaceIN2sw5redis14ConnectionPoolESaIS2_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv[_ZNSt23_Sp_counted_ptr_inplaceIN2sw5redis14ConnectionPoolESaIS2_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv]+0xc9): undefined reference to `redisFreeSSLContext'
/usr/bin/ld: test_main.cpp:(.text._ZNSt23_Sp_counted_ptr_inplaceIN2sw5redis14ConnectionPoolESaIS2_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv[_ZNSt23_Sp_counted_ptr_inplaceIN2sw5redis14ConnectionPoolESaIS2_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv]+0x1dd): undefined reference to `redisFreeSSLContext'
/usr/bin/ld: test_main.cpp:(.text._ZNSt23_Sp_counted_ptr_inplaceIN2sw5redis14ConnectionPoolESaIS2_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv[_ZNSt23_Sp_counted_ptr_inplaceIN2sw5redis14ConnectionPoolESaIS2_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv]+0x2e6): undefined reference to `redisFreeSSLContext'
/usr/bin/ld: test_main.cpp:(.text._ZNSt23_Sp_counted_ptr_inplaceIN2sw5redis14ConnectionPoolESaIS2_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv[_ZNSt23_Sp_counted_ptr_inplaceIN2sw5redis14ConnectionPoolESaIS2_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv]+0x515): undefined reference to `redisFreeSSLContext'
/usr/bin/ld: CMakeFiles/test_redis++.dir/src/sw/redis++/test_main.cpp.o: in function `sw::redis::SafeConnection::~SafeConnection()':
test_main.cpp:(.text._ZN2sw5redis14SafeConnectionD2Ev[_ZN2sw5redis14SafeConnectionD5Ev]+0x48a): undefined reference to `redisFreeSSLContext'
/usr/bin/ld: CMakeFiles/test_redis++.dir/src/sw/redis++/test_main.cpp.o:test_main.cpp:(.text._ZN2sw5redis14SafeConnectionD2Ev[_ZN2sw5redis14SafeConnectionD5Ev]+0x55e): more undefined references to `redisFreeSSLContext' follow
/usr/bin/ld: ../lib/libredis++.a(tls.cpp.o): in function `sw::redis::tls::secure_connection(redisContext&, sw::redis::tls::TlsOptions const&)':
tls.cpp:(.text+0xe8): undefined reference to `redisCreateSSLContext'
/usr/bin/ld: tls.cpp:(.text+0x100): undefined reference to `redisInitiateSSLWithContext'
/usr/bin/ld: ../lib/libredis++.a(tls.cpp.o): in function `sw::redis::tls::TlsInit::TlsInit()':
tls.cpp:(.text+0x55): undefined reference to `redisInitOpenSSL'
/usr/bin/ld: ../lib/libredis++.a(tls.cpp.o): in function `sw::redis::tls::secure_connection(redisContext&, sw::redis::tls::TlsOptions const&) [clone .cold]':
tls.cpp:(.text.unlikely+0x12): undefined reference to `redisSSLContextGetError'
/usr/bin/ld: tls.cpp:(.text.unlikely+0x161): undefined reference to `redisFreeSSLContext'
collect2: error: ld returned 1 exit status
make[2]: *** [test/CMakeFiles/test_redis++.dir/build.make:106: test/test_redis++] Error 1
make[1]: *** [CMakeFiles/Makefile2:172: test/CMakeFiles/test_redis++.dir/all] Error 2
make: *** [Makefile:150: all] Error 2

Also, when I try to install it anyway and compile a file using this code...
coderrediserror.png
and this command
erroredis.png

and if I do simply Redis("127.0.0.1") and assign it to a variable it throws a long list lof linker errors that look similar to the make error log I showed you above.
PLEASE HELP!

sewe...@gmail.com

unread,
Mar 15, 2021, 7:47:29 AM3/15/21
to Redis DB
It seems that you are trying to enable TLS support, but, somehow hiredis_ssl does not be linked correctly. Have you built hiredis with TLS enabled?  I cannot reproduce the problem.

Also, I recently rewritten the CMakeLists.txt, please checkout the latest code on master branch and have a try. If you still have the problem, please open an issue on [GitHub](https://github.com/sewenew/redis-plus-plus/issues).

Sorry for the late reply.

Regards

Maham M. Firdous

unread,
Mar 15, 2021, 7:55:26 AM3/15/21
to redi...@googlegroups.com
Yes. I built hiredis using the USE_SSL flag. Thank you for responding. I cloned the repo again and built it with TSL (compiler complains about SSL header file being missing even when I wanted to build it without TLS). 
There was an issue in my g++ command too. I was linking the static libraries by mistake.
Thank you so much for responding.

--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/eNvx-yz_BZw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/323f96d9-931a-40c3-ab18-e220ae8cdf44n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages