I need to write a c subroutine to do some win32 API stuff. However I am not very familiar with the command-line arguments that are used by cl. I have not been able to successfully build a XS module with cl so far. I created an empty module with
h2xs -X Mytest
I was also able to compile a DLL writing an XSC in Visual Studio IDE directly as per Dave roth's book "Win32: The standard Extensions" but this appears to be very painful. I'd much prefer to use perl's module building than constructing my own by hand. Any assistance would be very appreciated.

XS CODE

#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include <stdio.h> void hello (void) { printf("Hello World!"); } MODULE = Mytest PACKAGE = Mytest void hello()

Error Messages

Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cl -c -I. -nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CO +NSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IM +PLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -MD -Zi -DNDEBUG -O1 -DVERSION=\ +"0.01\" -DXS_VERSION=\"0.01\" "-IC:\Perl\lib\CORE" Mytest.c mytest.c c:\MSVC\INCLUDE\errno.h(29) : warning C4114: same type qualifier used +more than once c:\MSVC\INCLUDE\windows.h(130) : warning C4005: 'FALSE' : macro redefi +nition c:\MSVC\INCLUDE\windows.h(131) : warning C4005: 'TRUE' : macro redefin +ition c:\MSVC\INCLUDE\stdlib.h(108) : warning C4114: same type qualifier use +d more than once c:\MSVC\INCLUDE\stddef.h(44) : warning C4114: same type qualifier used + more than once C:/Perl/lib/CORE\win32.h(279) : error C2085: 'Perl_win32_init' : not i +n formal parameter list C:/Perl/lib/CORE\win32.h(280) : error C2061: syntax error : identifier + '__declspec' C:/Perl/lib/CORE\win32.h(281) : fatal error C1001: internal compiler e +rror (compiler file 'msc1.cpp', line 585) NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code + '0x2' Stop.
C:\Documents and Settings\sswenson\My Documents\perlscripts\Mytest>

Perl Configuration

Summary of my perl5 (revision 5 version 6 subversion 1) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef use5005threads=undef useithreads=define usemultip +licity=define useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cl', ccflags ='-nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE + -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLIC +IT_SYS -DPE RL_MSVCRT_READFIX', optimize='-O1 -MD -Zi -DNDEBUG', cppflags='-DWIN32' ccversion='', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=4 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -l +ibpath:"C:\Perl56\lib\CORE" -machine:x86' libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1. +1\Lib\" "C:\Perl56\lib\CORE" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netap +i32.lib uui d.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.l +ib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool +.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib n +etapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp +32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt: +ref,icf -libpath:"C:\Perl56\lib\CORE" -machine:x86' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEX +T PERL_IMPLICIT_SYS Locally applied patches: ActivePerl Build 635 Built under MSWin32 Compiled at Feb 4 2003 15:34:21 @INC: C:/Perl56/lib C:/Perl56/site/lib .

Environment

APPDATA=C:\Documents and Settings\sswenson\Application Data CommonProgramFiles=C:\Program Files\Common Files ComSpec=C:\WINDOWS\system32\cmd.exe INCLUDE=C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\in +clude\;c:\MSVC\INCLUDE;c:\MSVC\ALT\INCLUDE;c:\MSVC\MFC\INCLUDE LIB=C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\;c +:\MSVC\LIB;c:\MSVC\MFC\LIB LOGONSERVER=\\DEMESNE MAKEMSI_DIR=C:\Program Files\MakeMsi\ MAKEMSI_MSIVAL2_DIR=C:\Program Files\MSIVAL2 NUMBER_OF_PROCESSORS=1 OS=Windows_NT Path=C:\Perl56\bin\;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WIN +DOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Pane +l;C:\Progra m Files\MakeMsi\;C:\MSVC\BIN PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.4mm PPWIZARD_INCLUDE=C:\Program Files\MakeMsi\ PROCESSOR_ARCHITECTURE=x86 PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 7, GenuineIntel PROCESSOR_LEVEL=15 PROCESSOR_REVISION=0207 ProgramFiles=C:\Program Files PROMPT=$P$G REGINA_MACROS=C:\Program Files\MakeMsi\ SESSIONNAME=Console STAID=001 SystemDrive=C: SystemRoot=C:\WINDOWS TEMP=C:\DOCUME~1\sswenson\LOCALS~1\Temp TMP=C:\DOCUME~1\sswenson\LOCALS~1\Temp USERPROFILE=C:\Documents and Settings\sswenson VS71COMNTOOLS=C:\Program Files\Microsoft Visual Studio .NET 2003\Commo +n7\Tools\ windir=C:\WINDOWS

In reply to Need Help getting cl configured for making XS modules by talwyn

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.