ruven / iipsrv

iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images.
https://iipimage.sourceforge.io
GNU General Public License v3.0
292 stars 115 forks source link

Memcached support on Windows seems broken #226

Closed filak closed 2 years ago

filak commented 2 years ago

I have tried to build IIP with memcached using https://github.com/awesomized/libmemcached

But a source file "MemCacheClient.h" is missing in the repo:

https://github.com/ruven/iipsrv/blob/master/windows/MemcachedWindows.h#L30

ruven commented 2 years ago

In fact the Windows version used memcacheclient through the wrapper class in windows/MemcachedWindows.h because libmemcached wasn't Windows compatible. It looks like memcacheclient has long been abandoned, so it will be better to switch to something like libmemcached-awesome, which may even allow us to drop the wrapper.

Try simply dropping the MemcachedWindows.h file and include the libmemcached-awesome header directly instead and see if that works.

filak commented 2 years ago

I get some errors ie:

  Severity  Code    Description Project File    Line    Suppression State
  Error (active)    E0020   identifier "Memcache" is undefined  iipsrv  D:\Decko\iip\src\Main.cc    440 
  Error C2065   'Memcache': undeclared identifier   iipsrv  d:\decko\iip\src\main.cc    440 
  Error C2146   syntax error: missing ';' before identifier 'memcached' iipsrv  d:\decko\iip\src\main.cc    440 

https://github.com/ruven/iipsrv/blob/master/src/Main.cc#L440

ruven commented 2 years ago

Try commenting out lines 47, 48, 49 and 51 from Main.cc (the ifdef WIN32 block). Also make sure Memcached.h in the iipsrv/src/ directory is added to the project.

filak commented 2 years ago

I see... iipsrv/src/Memcached.h gets imported now but there seem to be some issues with the memcached library.

Many errors when compiling IIP - C2011, C2375

Severity    Code    Description Project File    Line    Suppression State
Error   C2011   'sockaddr': 'struct' type redefinition (compiling source file ..\..\src\Main.cc)    iipsrv  c:\program files (x86)\windows kits\10\include\10.0.17763.0\shared\ws2def.h 235 
...
Error   C2011   'fd_set': 'struct' type redefinition (compiling source file ..\..\src\Main.cc)  iipsrv  c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\winsock2.h   136 
...
Error   C2375   'accept': redefinition; different linkage (compiling source file ..\..\src\Main.cc) iipsrv  c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\winsock2.h   1625    

I am not sure how to resolve this.

ruven commented 2 years ago

It looks like these are probably due to the Windows headers being included more than once (Error C2011 is: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2011?view=msvc-170). I presume the first include is happening in libfcgi.

Try modifying the libmemcached header file (https://github.com/awesomized/libmemcached/blob/bcc1a6ecf1eadcf69dd9efa02fee69ee63949ca0/include/libmemcached-1.0/platform.h#L58) and add #pragma once just before the winsock include. You won't need to recompile libmemcached hopefully.

By the way, I presume you are building iipsrv using the steps you wrote here: https://github.com/filak/IIPImage-on-Windows with VS 2017 Community? So, libmemcached doesn't in fact work when you follow these steps?

filak commented 2 years ago

It looks like there are circular includes/dependencies. I have tried to add pragma once as suggested (though it is already on line 16) but it made no difference.

I am not 100% sure how to integrate the libmemcached library (I have followed your fcgi folder pattern) - the IIPImage-on-Windows repo is up to date on what I have tried/done so far.

Without the HAVE_MEMCACHED directive IIP in VS2017 compiles just fine.

ruven commented 2 years ago

OK, I've finally managed to get a Windows development environment up and running! I followed your steps and I built libmemcached myself using cmake rather than use the binaries. To get the whole thing to compile you just need to add the following line to the top of src/Memcached.h:

#undef _WIN32

This stops platform.h including the 2 headers. I presume they have already been included by the FCGI library, which is what is causing the compilation issue.

The binary seems to work and the log file says memcached is active, but I haven't installed Memcached yet to test whether it's really doing something.

filak commented 2 years ago

Thank you for your effort. It builds fine now. I will test it with Memcached running and let you know if it works.

filak commented 2 years ago

I can confirm now that IIP works with Memcached on Windows.

So I am closing this issue.

I will do some more testing for sure...