Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

XS problems on win32

by talwyn (Monk)
on Dec 11, 2005 at 08:28 UTC ( [id://515802]=perlquestion: print w/replies, xml ) Need Help??

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

I am having difficulty getting an XS module I wrote connected to a c++ class I wrote to compile.

The class works when compiled in c++ but the xs translation seems to fail. The error message seems to say that there are syntax errors in the cstdio include file.... which I doubt.

XS Module
#ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifdef __cplusplus } #endif #include "stopwatch.h" MODULE = Stopwatch PACKAGE = Stopwatch stopwatch * stopwatch::new() void stopwatch::DESTROY() void stopwatch::start() double stopwatch::stop () void stopwatch::reset() double stopwatch::DisplayAvg() void stopwatch::lap ()
Error message:
Microsoft (R) Program Maintenance Utility Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved. cl -c -I. -nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CO +NSOLE -DNO _STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT -DPER +L_IMPLICIT _SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -MD -Zi -DNDEBUG -O1 -DVERS +ION=\"0.01 \" -DXS_VERSION=\"0.01\" "-IC:\Perl\lib\CORE" stopwatch.c cl : Command line warning D4029 : optimization is not available in the + standard edition compiler stopwatch.c c1 : warning C4349: /Gf is deprecated and will not be supported in fut +ure versio ns of Visual C++; remove /Gf or use /GF instead C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio( +17) : error C2143: syntax error : missing '{' before ':' C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio( +17) : error C2059: syntax error : ':' C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio( +17) : error C2143: syntax error : missing '{' before ':' C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio( +17) : error C2059: syntax error : ':' C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio( +17) : erro
MAKEFILE.PL
use 5.008006; use ExtUtils::MakeMaker; $CC = 'cl'; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Stopwatch', VERSION_FROM => 'lib/Stopwatch.pm', # finds $VERSION PREREQ_PM => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Stopwatch.pm', # retrieve abstract from +module AUTHOR => 'A. U. Thor <a.u.thor@a.galaxy.far.far.away>' +) : ()), LIBS => [''], # e.g., '-lm' DEFINE => '', # e.g., '-DHAVE_SOMETHING' CC => $CC, LD => $CC, CCFLAGS => '', INC => '-I.', # e.g., '-I. -I/usr/include/other' # Un-comment this if you add C files to link with later: OBJECT => '$(O_FILES)', # link all the C files too XSOPT =>'-C++', TYPEMAPS =>['perlobject.map'], );
perl Specs:
Summary of my perl5 (revision 5 version 8 subversion 6) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef usethreads=define use5005threads=undef useithreads=define usemulti +plicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D +_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DPERL_IMPLICI +T_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX', optimize='-MD -Zi -DNDEBUG -O1', 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='__int64 +', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -l +ibpath:"C:\Perl\lib\CORE" -machine:x86' libpth=\lib libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netap +i32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib + odbccp32.lib 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 ws2_32.lib mpr.lib winmm.lib version.lib odbc32 +.lib odbccp32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib gnulibc_version='undef' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt: +ref,icf -libpath:"C:\Perl\lib\CORE" -machine:x86' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL +_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS Locally applied patches: ActivePerl Build 811 21540 Fix backward-compatibility issues in if.pm 23565 Wrong MANIFEST.SKIP Built under MSWin32 Compiled at Dec 13 2004 09:52:01 @INC: C:/Perl/lib C:/Perl/site/lib .
Compiler Specs

Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.10.3077 for 80x86

Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

Replies are listed 'Best First'.
Re: XS problems on win32
by BrowserUk (Patriarch) on Dec 11, 2005 at 09:30 UTC

    Isn't stopwatch::new() C++ syntax, but your file is called stopwatch.c, which by default will be compiled as a C rather than C++ source file. I don't see any switch (like: /TP) that would cause it to be otherwise.

    I don't have a file called cstudio(.h?) installed on my version of the compiler, so I can't look inside to see if that also contains C++ syntax. If it does, and it is included from a .c source file, that would perhaps explain the syntax errors?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      In c:\program files\Microsoft Visual Studio .NET 2003\Vc7\include

      I believe its a wrapper to allow C routines to have access to stdio.

Re: XS problems on win32
by PodMaster (Abbot) on Dec 11, 2005 at 09:26 UTC
    Get rid of the #ifdef __cplusplus stuff, and XSOPT =>'-C++' (it does nothing). Add DEFINE => ' -TP ', and try again.

    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.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Tried that. more and different errors:
        You could also try moving #include "stopwatch.h" before the perl xs includes, worked for me before (see Re: perlxs and c++ : dosish.h(111) : warning C4005: 'Stat' : macro redefinition), but thats a shot in the dark. If you want more help you should try posting stopwatch.h along with other files needed to try to compile this module.

        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.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-18 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found