cpp-redis / cpp_redis

C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform
MIT License
713 stars 198 forks source link

Cannot build latest version due to tacopie dependency #105

Open ScarletGuo opened 1 year ago

ScarletGuo commented 1 year ago

Hi Team,

Describe the bug

Thanks for maintaining the code! I recently tried to build using Cmake but it failed due to the following error

/users/xxx/cpp_redis/includes/cpp_redis/network/tcp_client.hpp:28:10: fatal error: tacopie/tacopie: No such file or directory
 #include <tacopie/tacopie>

Possible workaround

it works when I reverted back to commit ab5ea8638bc51e3d407b0045aceb5c5fd3218aa0

Desktop

Ubuntu 18.04.1 LTS

lindblandro commented 1 year ago

Seems like the build file is broken due to unmerged changes in tacopie. If you use the patches from https://github.com/cpp-redis/tacopie/pull/5 the build looks like this:

cpp_redis]$ cc --version
cc (GCC) 12.2.1 20220819 (Red Hat 12.2.1-2)
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cpp_redis]$ cmake --version
cmake version 3.24.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

cpp_redis]$ mkdir -p build
cpp_redis]$ cd build/
cpp_redis/build]$ cmake ..
-- The CXX compiler identification is GNU 12.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
cpp_redis/build]$ make
[  3%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/network/common/tcp_socket.cpp.o
[  7%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/network/io_service.cpp.o
[ 10%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/network/tcp_client.cpp.o
[ 14%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/network/tcp_server.cpp.o
[ 17%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/utils/error.cpp.o
[ 21%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/utils/logger.cpp.o
[ 25%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/utils/thread_pool.cpp.o
[ 28%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/network/unix/unix_self_pipe.cpp.o
[ 32%] Building CXX object tacopie/CMakeFiles/tacopie.dir/sources/network/unix/unix_tcp_socket.cpp.o
[ 35%] Linking CXX shared library ../lib/libtacopie.so
[ 35%] Built target tacopie
[ 39%] Building CXX object CMakeFiles/cpp_redis.dir/sources/builders/array_builder.cpp.o
[ 42%] Building CXX object CMakeFiles/cpp_redis.dir/sources/builders/builders_factory.cpp.o
[ 46%] Building CXX object CMakeFiles/cpp_redis.dir/sources/builders/bulk_string_builder.cpp.o
[ 50%] Building CXX object CMakeFiles/cpp_redis.dir/sources/builders/error_builder.cpp.o
[ 53%] Building CXX object CMakeFiles/cpp_redis.dir/sources/builders/integer_builder.cpp.o
[ 57%] Building CXX object CMakeFiles/cpp_redis.dir/sources/builders/reply_builder.cpp.o
[ 60%] Building CXX object CMakeFiles/cpp_redis.dir/sources/builders/simple_string_builder.cpp.o
[ 64%] Building CXX object CMakeFiles/cpp_redis.dir/sources/core/client.cpp.o
[ 67%] Building CXX object CMakeFiles/cpp_redis.dir/sources/core/consumer.cpp.o
[ 71%] Building CXX object CMakeFiles/cpp_redis.dir/sources/core/reply.cpp.o
[ 75%] Building CXX object CMakeFiles/cpp_redis.dir/sources/core/sentinel.cpp.o
[ 78%] Building CXX object CMakeFiles/cpp_redis.dir/sources/core/subscriber.cpp.o
[ 82%] Building CXX object CMakeFiles/cpp_redis.dir/sources/core/types.cpp.o
[ 85%] Building CXX object CMakeFiles/cpp_redis.dir/sources/misc/dispatch_queue.cpp.o
[ 89%] Building CXX object CMakeFiles/cpp_redis.dir/sources/misc/logger.cpp.o
[ 92%] Building CXX object CMakeFiles/cpp_redis.dir/sources/network/redis_connection.cpp.o
[ 96%] Building CXX object CMakeFiles/cpp_redis.dir/sources/network/tcp_client.cpp.o
[100%] Linking CXX shared library lib/libcpp_redis.so
[100%] Built target cpp_redis
lindblandro commented 1 year ago

The tacopie submodule needs to be updated once the linked tacopie PR is merged.

soykotnext commented 1 year ago

@ScarletGuo @lindblandro still facing tacopie issue in Ubuntu.

lindblandro commented 1 year ago

@soykotnext Can you describe what you did between your initial and second attempt?

soykotnext commented 1 year ago

Clone the project

git clone https://github.com/cpp-redis/cpp_redis.git

Go inside the project directory

cd cpp_redis

Get tacopie submodule

git submodule init && git submodule update

Create a build directory and move into it

mkdir build && cd build

Generate the Makefile using CMake

cmake .. -DCMAKE_BUILD_TYPE=Release

After this command, I got this error message.

-- The CXX compiler identification is GNU 11.3.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Deprecation Warning at tacopie/CMakeLists.txt:26 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.

Update the VERSION argument value or use a ... suffix to tell CMake that the project does not need compatibility with older versions.

CMake Warning (dev) at tacopie/CMakeLists.txt:41 (project): Policy CMP0048 is not set: project() command manages VERSION variables. Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

-- Looking for C++ include pthread.h -- Looking for C++ include pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE
-- Configuring done CMake Error: install(EXPORT "cpp_redis" ...) includes target "cpp_redis" which requires target "tacopie" that is not in any export set. -- Generating done CMake Generate step failed. Build files cannot be regenerated correctly.

@lindblandro

lindblandro commented 1 year ago

Add a step after you update your submodules:

cd tacopie
git fetch origin pull/5/head:cmake-fixes
git checkout cmake-fixes
cd ..

Reason being that the tacopie submodule points to the wrong thing. There is a PR to tacopie that needs to be merged (waiting for approval) and then another PR needs to be done here to update the submodule. Submodules are fun.

soykotnext commented 1 year ago

@lindblandro thanks, man.

jgwinner commented 1 year ago

I'm looking for the tacopie fix as well.

I updated that thread also. Our CI/CD chain of course fails.

I forked the code, did my own PR (Thanks @lindblandro !) and that fixed it for now. I'll delete my fork once this is fixed.

jgwinner commented 1 year ago

@lindblandro Hi Henrik. Your changes were great, and I got a lot further, but I'm still having an issue:

[28/28] Linking CXX shared library bin\cpp_redis.dll
  FAILED: bin/cpp_redis.dll lib/cpp_redis.lib 
  cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_dll --intdir=CMakeFiles\cpp_redis.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cpp_redis.dir\sources\builders\array_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\builders_factory.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\bulk_string_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\error_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\integer_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\reply_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\simple_string_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\client.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\consumer.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\reply.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\sentinel.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\subscriber.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\types.cpp.obj CMakeFiles\cpp_redis.dir\sources\misc\dispatch_queue.cpp.obj CMakeFiles\cpp_redis.dir\sources\misc\logger.cpp.obj CMakeFiles\cpp_redis.dir\sources\network\redis_connection.cpp.obj CMakeFiles\cpp_redis.dir\sources\network\tcp_client.cpp.obj  /out:bin\cpp_redis.dll /implib:lib\cpp_redis.lib /pdb:bin\cpp_redis.pdb /dll /version:0.0 /machine:x64 /debug /INCREMENTAL  lib\tacopie.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib  && cd ."
  LINK Pass 1: command "C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cpp_redis.dir\sources\builders\array_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\builders_factory.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\bulk_string_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\error_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\integer_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\reply_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\builders\simple_string_builder.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\client.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\consumer.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\reply.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\sentinel.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\subscriber.cpp.obj CMakeFiles\cpp_redis.dir\sources\core\types.cpp.obj CMakeFiles\cpp_redis.dir\sources\misc\dispatch_queue.cpp.obj CMakeFiles\cpp_redis.dir\sources\misc\logger.cpp.obj CMakeFiles\cpp_redis.dir\sources\network\redis_connection.cpp.obj CMakeFiles\cpp_redis.dir\sources\network\tcp_client.cpp.obj /out:bin\cpp_redis.dll /implib:lib\cpp_redis.lib /pdb:bin\cpp_redis.pdb /dll /version:0.0 /machine:x64 /debug /INCREMENTAL lib\tacopie.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cpp_redis.dir/intermediate.manifest CMakeFiles\cpp_redis.dir/manifest.res" failed (exit code 1104) with the following output:
C:\c\cpp-orig\cpp_redis\out\build\x64-Debug\LINK : fatal error LNK1104: cannot open file 'lib\tacopie.lib'
jgwinner commented 1 year ago

I had also found out that when you declare a git submodule, when you do the pull for the parent it doesn't update the children. The submodule ends up as a detached HEAD to the commit when you added the submodule. So when I applied your changes, it didn't 'take'.

You've got to do this:

git submodule update --remote --merge

then commit.

VERY frustrating. Turned out, my CMAKE subproject was pulling the latest changes, but the parent project was reverting to the previous, unfixed / unmerged tacopie commit.

Got through that and get the lib error. Taking a look at that ...

lindblandro commented 1 year ago

@jgwinner Seems there are some issues with the Windows build. The build files for both cpp_redis and tacopie are still littered with conditionals for different platforms. Windows build in particular might be broken as the CI doesn't verify it. Don't know if Windows builds are possible with the current CI setup without paying something for the pleasure.

jgwinner commented 1 year ago

Thanks.

Honestly, I just went back to a previous version (git checkout )to get past the build, and haven't looked at it.

Maybe I'm the one that needs to do it ...

lindblandro commented 1 year ago

I don't have access to a Windows machine, otherwise I could also take a look at a fix. Most likely it's nothing major since the project configures and compiles ok. It's just linking that seems to be broken, which usually means that the target types or parameters are incorrect. I'm not familiar on how MSVC does things, though.

EDIT: I do think the project maintainers could perhaps react a bit faster.