Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Need Help getting cl configured for making XS modules

by talwyn (Monk)
on Mar 20, 2004 at 15:11 UTC ( [id://338298]=perlquestion: print w/replies, xml ) Need Help??

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

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

Replies are listed 'Best First'.
Re: Need Help getting cl configured for making XS modules
by Aragorn (Curate) on Mar 20, 2004 at 18:27 UTC
    I have no experience with Win32 programming, but I think what you're trying to do can be done much more easily with SWIG. The Introduction of the documentation is a good overview of what it can do. XS programming is tricky, to say the least, and SWIG takes a lot of work out of your hands. The examples in the introduction are on a Unix system, but it works with Windows (Visual Studio, Cygwin, etc) too.

    Added bonus is that your C module can be compiled to work with other languages as well.

    Arjen

      Thanks for your help... I tried Swig... it appears that the problem is the compiler configuration. swig created a xsc module with no problem but would not compile.... something is not set right for the commandline compiler. I am still looking for the info that will help me fix it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://338298]
Approved by calin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-26 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found