Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
If you wish to avoid modifying the registry, simply run vcvars32.bat which will set up the appropriate environment variables (modify PATH, add LIB and INCLUDE) before attempting to nmake. vcvars32.bat is specific to MSVS6, but i'm sure MSVS .NET has a similary named batch file which will setup the environment. It's located right next to CL.exe.

I'd really like to stress the importance of reading the README/INSTALL that come with modules. They'll often have common problems( and usually their solutions) others have had trying to compile said extension on win32.

I'd also like to add that you should not be afraid of editing Makefile.PL. Get familiar with ExtUtils::MakeMaker. Most of the time you can get away with modifying your INCLUDE/LIBS environment variables, but not all Makefile.PL's are created equal, and some are written quite poorly (in a non-portable fashion, for no apparent reason -- for example, WriteMakefile is passed 'OBJECT' => '$(O_FILES) '." Foo.o Bar.o Baz.o " which won't fly on windows. The right way to write it would've been as "Foo$Config{obj_ext} Bar$Config{obj_ext} Baz$Config{obj_ext}").

Another common portability issue is #include <uninstd.h>. Lots of extensions include it, but windows has no such beast, and it belongs in an #ifndef. Simply comment it out, and there'll be a good chance the extension will compile.

Also, if a required library will not build on windows, all hope is not lost. You can always get MinGW (aka cygwin), compile the required library, and link with it.

Read How can an MSVC program call a MinGW DLL, and vice versa? on how to do it.

I recently did that with Math::GMP (it's up on my repository), cause it's a requirement for Net::SSH::Perl. If you can live with running GMP via cygwin, you can have Math::GMP on windows.

It is also important to make sure when compiling libraries required for a module to work, like in the case of pure-db, that your compiler options match those of your perl binary. CL /? will reveal the following possible options

-LINKING- /MD link with MSVCRT.LIB /MDd link with MSVCRTD.LIB de +bug lib /ML link with LIBC.LIB /MLd link with LIBCD.LIB debu +g lib /MT link with LIBCMT.LIB /MTd link with LIBCMTD.LIB de +bug lib /LD Create .DLL /F<num> set stack size /LDd Create .DLL debug libary /link [linker options and lib +raries]
What you want is what your perl has
perl -V:ccflags ccflags='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAV +E_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVC +RT_READFIX';
So you'd wanna make sure the -MD option is present. A tell-tale sign that the library you're trying to link to was not compiled with the -MD option is an "unresolved external symbol _pctype".

If you're faced with an error, google it, check rt.cpan.org, check testers.cpan.org (the mailing list archives as well) because chances are, somebody has already encountered it and there is a workaround available, and if there isn't, simply report it to the author, cause he'll usually be able to help you.

update: If you get unresolved external symbol _snprintf, you'll need (this is not like the _pctype issue):

#ifdef WIN32 #define snprintf _snprintf #endif


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
** The Third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: A Practical Guide to Compiling C based Modules under ActiveState using Microsoft C++ by PodMaster
in thread A Practical Guide to Compiling C based Modules under ActiveState using Microsoft C++ by tachyon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (7)
    As of 2014-07-13 23:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (252 votes), past polls