Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-03-19 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found