sewenew / redis-plus-plus

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

Cannot link to hiredisd.dll - get fatal error LNK1107: invalid or corrupt file #477

Closed andrewjohnstonn closed 1 year ago

andrewjohnstonn commented 1 year ago

When trying to link to the hiredisd.dll from my redis-plus-plus cmake I get the following error:

hiredis\build\Debug\hiredisd.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x350 [D:\BACCHUS\redis\build\Redis\redis-plus-plus\redis++.vcxproj]

I have run the hiredis-test.exe and it passes, I have also rebuilt hiredis multiple times with no success. It builds if I use the hiredis static lib but my application will not run if I do this, and if I run the redis-plus-plus test exe it says that it cannot find the hiredisd.dll file.

Wondering if this is a common issue and if there is a solution to it?

Cheers

sewenew commented 1 year ago

I'm not familiar with Windows environment. But looks like you should link to xxx.lib instead xxx.dll. Check this link for detail.

Also you should ensure that both hiredis and redis-plus-plus should be built with the same compilation settings, say, both compiled with x64 Debug, or both compiled with x86 Release, and so on.

Regards

andrewjohnstonn commented 1 year ago

Okay thanks.

One more thing is when I try to run the Redis++ test with the following command on Windows (tried bash shell and cmd):

./test_redis++.exe -h 127.0.0.1 -p 6379

I get a Test failed: ERR unknown command 'TOUCH'

Do you know how you ran your tests on windows?

Note: The dll problem when running this test was fixed by adding the path to the hiredisd.dll to the PATH system environmental variable.

sewenew commented 1 year ago

In order to use TOUCH, you should have a Redis version higher than 3.2.1. Please check your Redis version. Also Redis commands can be renamed / disabled with configuration. You should check your Redis configuration if this command has been disabled.

In order to run Redis tests, you need to install latest Redis. Since Redis is evolving, old version Redis cannot support new commands. Check the doc for Redis requirements for testing.

Regards

andrewjohnstonn commented 1 year ago

Hi,

The issue was I had Redis for Windows installed, which must be an older version. The Redis++ tests pass once uninstalled. I recommend you add to the windows section to add the hiredisd.dll to your PATH on windows.

Cheers!