erikajohns / puz

Automatically exported from code.google.com/p/puz
0 stars 0 forks source link

compiling libpuz and readpuz on Windows with MinGW32 #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Got this to build on Windows.  Wanted to document the changes it required just 
in case anyone has a need for this.  It does not compile for Windows without 
modification.

Added the following files to the build since Windows doesn't offer memory 
mapping:
http://code.google.com/p/mman-win32/source/browse/trunk/mman.h
http://code.google.com/p/mman-win32/source/browse/trunk/mman.c

Windows is also missing a strndup function, so I added the code for a version I 
wrote to the build:
#include <string.h>
#include <stdlib.h>

char *strndup (const char *s, size_t size)
{
   int sz = strlen (s); 
   if (sz > size)
      sz = size;
   char *retval = (char *) malloc (sz + 1);
   {
      memcpy( retval, s, sz);
      retval[sz] = '\0';
   }
   return (retval);
}

Once those are added to the Win32 build, it builds fine on Windows using 
MinGW32.  Was able to get readpuz.exe to execute on a Windows system.

Original issue reported on code.google.com by lme...@gmail.com on 22 Jan 2013 at 7:11