sewenew / redis-plus-plus

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

[BUG] it seems both HIREDIS_LIB and TEST_HIREDIS_LIB should be set to the static lib FILEPATH on Windows #364

Closed icelee123 closed 1 year ago

icelee123 commented 2 years ago

when set to dll, link.exe failed. the document is misleading

sewenew commented 2 years ago

Sorry for the misleading info, but I'm not familiar with Windows building environment. Can you create a PR to fix the doc, or even better make the doc more precisely? Thanks a lot!

Regards

Asphalt415 commented 1 year ago

On Windows you can have hiredis-lib folder holds hiredis project from github and a lib folder. Copy lib file into lib folder. After specifying the absolute path of hiredis-lib for cmake argument DCMAKE_PREFIX_PATH="Your hiredis-lib Absolute Path", in this way you should solve the problem

sewenew commented 1 year ago

@GorZ3rk Thanks a lot for your contribution!

I also post your PR under this issue, so that if someone searches the issue list can find your building steps. If you have problem with it, feel free to let me know, and I'll remove it.

The following building steps are given by @GorZ3rk and tested with VS 2022:

==================================

Build with Visual Studio

If you want to build the project with Visual Studio and have questions about it, please follow the steps below. The following is tested on Visual Studio 2022 Community.

 # download two projects into this folder
 mkdir redis++
 cd redis++
 # make sure you create a hiredis first to work as a library
 mkdir hiredis-lib
 cd hiredis-lib
 mkdir lib
 git clone https://github.com/redis/hiredis.git
 cd hiredis

So far it should be fine with each step. Then open CMakeLists.txt file. Modify the following line and comment it out

 ...
 # SET(CMAKE_DEBUG_POSTFIX d)
 ...

Then go back to hiredis project folder

 mkdir build
 cd build
 # convert project into visual studio 2022, if necessary choose you version e.g 19 2019 etc.
 cmake -G "Visual Studio 17 2022" ..
 ./hiredis.sln

Set hiredis as Startup Project then click Build Solution in Debug Mode

After successfull build, copy all the files under Debug into hiredis-lib/lib folder

Here the work for hiredis should be finished.

Then go back to redis++ folder. Open Terminal here

 git clone https://github.com/sewenew/redis-plus-plus.git
 cd redis-plus-plus
 mkdir build
 cd build

Now you should always have openssl on your PC, otherwise can use chocolatey to install it. For Visual Studio 2022 please install pthread separately using vpckg, following this link

After all preparation. If you want to convert all projects then

 cmake -DCMAKE_PREFIX_PATH="$(ABSOLUTE_PATH)\hiredis-lib" -G "Visual Studio 17 2022" ..
 cd build
 ./redis++.sln

set redis++_static as Startup Project then click Build Solution

So far build has been successfully finished!