http://www.perlmonks.org?node_id=482354

jk2addict has asked for the wisdom of the Perl Monks concerning the following question:

First of all, I know exactly jack squat about c/cpp or xs. Be gentle. I've tried to read the how tos for XS, but it makes my brain hurt.

For the longest time I've wanted Data::UUID on win32. When I started on Handel, I had looked into using Class::DBI::UUID for the primary columns, but the fact that it required Data::UUID and Data::UID didn't compile on win32 left me out of luck. I instead turned to using any of the various GUID/UUID modules on CPAN; using whatever the user had installed. Sometimes that was Data::UUID, or Win32::GUIDgen, Win32API::GUID or UUID. Life was good.

Today I cought the tinker bug and decided to get Data::UUID to compile on win32 come hell or high water. Not knowing a damn thing about c and any Makefile.PL->xs/linker magic, I actually managed to make it work.

There were two problems, first there was Makefile.PL errors:

C:\Data-UUID-0.11>perl Makefile.PL Checking if your kit is complete... Looks good UUID state storage (/var/tmp): C:\ default umask (0007): Note (probably harmless): No library found for -lsocket Writing Makefile for Data::UUID

I ignored that for the time being. Then there was the compile/linker errors. All I did was turn the top of UUID.h from this:

#include <string.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <time.h> #include "md5.h"

into this

#define __CYGWIN__ #include <string.h> #include <stdio.h> #include <stdlib.h> //#include <unistd.h> #include <time.h> #include "md5.h"

Now, nmake compiles and links the dll without errors and nmake test passes completely. Awesome. So, what's the problem you may ask? I'd like to submit the necessary patches to the author but I have no idea what the hell I just did or what to actually tweak in Makefile.PL/.h/.c

First, Data::UUID appears to run under CYGWIN and MING32. But of course on win32, neither of those are defined; hence the #define __CYGWIN__ line. Is there some magic that goes in Makefile.PL to get __CYGWIN__ defined or is that part of the compilers ENV?

Second, what about that "No library found" error? Should I simply ditch the LIBS => 'lsocket' def is we're on MSWin32?

I'm sure I could just describe my fixes to the author and wash my hands of it, but I wouldn't learn much that way.

-=Chris

Considered (GrandFather): move to meditations.
Unconsidered (holli): Enough Keep Votes (Keep/Edit/Delete: 11/14/1)