in reply to Re^7: How do I call C++ Dll's class Function in perl using Win32::API
in thread How do I call C++ Dll's class Function in perl using Win32::API

Hi, parallely trying to use Inline::CPP also but not successfull.
Inline.Test.pl
#!/usr/bin/perl
use strict;
use warnings;
use Inline CPP => Config =>
AUTO_INCLUDE => '#include "stdafx.h"',
LIBS => ' -L/D:\Documents and Settings\M1009280\My Documents\Visual Studio 2005\Projects\Test\Test -lTest.lib',
INC => '-I D:\Documents and Settings\M1009280\My Documents\Visual Studio 2005\Projects\Test\Test\Test.h',
INC => '-I C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE',
PREFIX => 'Test',
ENABLE => 'STD_IOSTREAM',
BUILD_NOISY =>1;
use Inline CPP => <<'EOC';
#include <Test.h>
int test(int a){
a *= 2;
return a;
}
EOC
my $result = int test(2);
print "$result\n";


Executing the above script following error appears
C:\Perl\bin>perl Inline.Test.pl
Starting Build Preprocess Stage
Finished Build Preprocess Stage
Starting Build Compile Stage
Starting "perl Makefile.PL" Stage
Note (probably harmless): No library found for y
Note (probably harmless): No library found for and
Note (probably harmless): No library found for
Settings/M1009280/My
Note (probably harmless): No library found for Documents/Visual
Note (probably harmless): No library found for Studio
Note (probably harmless): No library found for 2005/Projects/Test/Test
Note (probably harmless): No library found for -lTest.lib Writing Makefile for Inline_Test_pl_89e7
Finished "perl Makefile.PL" Stage
Starting "make" Stage
Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils\xsubpp -typemap C:\Perl\lib\E xtUtils\typemap Inline_Test_pl_89e7.xs > Inline_Test_pl_89e7.xsc && C:\Perl\bin \perl.exe -MExtUtils::Command -e mv Inline_Test_pl_89e7.xsc Inline_Test_pl_89e7. c
cl -TP -c -IC:/Perl/bin -I C:\Program Files\Microsoft Visual Studio 8\V C\ATLMFC\INCLUDE -nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_S TRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICI T_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -MD -Zi -DNDEBU G -O1 -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" "-IC:\Perl\lib\CORE" Inlin e_Test_pl_89e7.c
Microsoft c1xx : fatal error C1083: Cannot open source file: 'Files\Microsoft': No such fi le or directory Visual
c1xx : fatal error C1083: Cannot open source file: 'Visual': No such file or dir ectory Studio
c1xx : fatal error C1083: Cannot open source file: 'Studio': No such file or dir ectory INCLUDE
c1xx : fatal error C1083: Cannot open source file: '8\VC\ATLMFC\INCLUDE': No such file or directory Inline_Test_pl_89e7.c
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\xlocale(326) : warning C45 30: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\xlocale(341) : warning C45
30: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\xlocale(358) : warning C45 30: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\istream(1075) : warning C4 530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE\afx.h(24) : fatal error C1189: #error : Building MFC application with /MDd (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MDdGenerating Code...
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\cl.EXE"' : return code '0x2' Stop.
A problem was encountered while attempting to compile and install your Inline
CPP code. The command that failed was:
nmake

The build directory was:
C:\Perl\bin\_Inline\build\Inline_Test_pl_89e7

To debug the problem, cd to the build directory, and inspect the output files.

at Inline.Test.pl line 16
BEGIN failed--compilation aborted at Inline.Test.pl line 24.
Since i had problem while linking the VCC++ Header files i had to go for Win32::API approach
Please let me know if my approach wirting the above Inline_Test.pl script if correct?
  • Comment on Re^8: How do I call C++ Dll's class Function in perl using Win32::API

Replies are listed 'Best First'.
Re^9: How do I call C++ Dll's class Function in perl using Win32::API
by BrowserUk (Patriarch) on Mar 13, 2009 at 06:55 UTC

    I've never used INline::CPP (I hate C++ with a vengence!), but it seems fairly obvious from the errors you've posted that the first thing you need to do is quote any paths that contain spaces.

    Eg,

    LIBS => ' -L/D:\Documents and Settings\M1009280\My Documents\Visual St +udio 2005\Projects\Test\Test -lTest.lib',

    Should be:

    LIBS => '"-L/D:\Documents and Settings\M1009280\My Documents\Visual St +udio 2005\Projects\Test\Test -lTest.lib"',
    etc.

    NOTE: the "s embedded inside 's.

    I'm not saying that will fix everything, but it might move you along a little. If you're lucky, someone who has used Inline::CPP will chime in about now.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Hi No major changes seen even after changing the quotes ""
      I would be really thankfull to u if u can tell me how do i handle "Name Mangling" in perl shile calling the C++ Class.
Re^9: How do I call C++ Dll's class Function in perl using Win32::API
by Anonymous Monk on Mar 13, 2009 at 07:14 UTC