Click here to get back home

Access a c++ module from Perl

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Access a c++ module from Perl bg-greece 10-24-2005
Posted by bg-greece on October 24, 2005, 6:21 pm
Please log in for more thread options


I am using cygwin and perl and trying to access some function from a C++
windows dll. After the first attempt produced a segmentation fault, I tried
to do it step-by-step. I created a dummy function in the dll file:

int TestDLL(int x)
{
return 1;
}


and put the following code in a perl file:

use strict;
use Win32::API::Prototype;

my $TestDLL = ApiLink("mydll",'I TestDLL(I x)');
if (not defined $TestDLL) {
die "Can't import API TestDLL: $! \n";
}
print "ApiLink done\n";

my $xx = 0;
my $return = $TestDLL->Call($xx);
print $return."\n";


But even this produces a segmentation fault (core dump). Any ideas?

BG




Posted by John Bokma on October 24, 2005, 3:35 pm
Please log in for more thread options



> I am using cygwin and perl and trying to access some function from a
> C++ windows dll. After the first attempt produced a segmentation
> fault, I tried to do it step-by-step. I created a dummy function in
> the dll file:

....

> But even this produces a segmentation fault (core dump). Any ideas?

Just a very wild guess: you wrote Cygwin. How did you make the DLL? Inside
Cygwin, or outside it?

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
I ploink googlegroups.com :-)



Posted by bg-greece on October 25, 2005, 12:00 pm
Please log in for more thread options


the dll was created with with Microsoft Visual C++ 6.0


> Just a very wild guess: you wrote Cygwin. How did you make the DLL? Inside
> Cygwin, or outside it?
>
> --
> John Small Perl scripts: http://johnbokma.com/perl/
> Perl programmer available: http://castleamber.com/
> I ploink googlegroups.com :-)
>




Posted by harryfmudd [AT] comcast [DOT] on October 25, 2005, 2:51 pm
Please log in for more thread options


bg-greece wrote:
> the dll was created with with Microsoft Visual C++ 6.0

Are you using the Cygwin distribution of Perl? I think you will find
that it was _not_ made with Visual C++ V6, but with gcc.

I personally have had good luck with Win32::API, though sometimes it was
not obvious how to describe the function I wanted to import, and when
you get the description wrong, you do get segment violations. I do not
remember using the new, sexy prototype interface, just the old, clunky
one. See Win32::Process::Info::NT for an example.

Disclaimer: I wrote the cited module. And I never said it was a _good_
example.

Tom Wyant


Posted by John Bokma on October 26, 2005, 12:50 am
Please log in for more thread options



>> Just a very wild guess: you wrote Cygwin. How did you make the DLL?
>> Inside Cygwin, or outside it?

> the dll was created with with Microsoft Visual C++ 6.0

That might cause the problem(s) you see.

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
I ploink googlegroups.com :-)



Similar ThreadsPosted
Perl under MS IIS with access to MySQL June 19, 2005, 11:24 pm
pure-perl access to mySQL June 14, 2005, 8:38 am
new module Logfile::Access October 23, 2004, 8:30 pm
Announce: Win32::SqlServer - access SQL Server from Perl November 27, 2005, 5:03 pm
Module to use for win32 registry access? April 4, 2007, 8:32 pm
XP, Perl, Win32::ODBC, Microsoft Access 2002 SP3, & Chinese characters January 22, 2008, 4:18 pm
Do Win32::ODBC module support Chinese characters when used with MS Access? September 15, 2004, 10:33 pm
Microsoft Access & Win32::Ole October 28, 2005, 4:03 pm
Access DOM using JavaScript::SpiderMonkey January 16, 2006, 12:37 pm
compiling/add modules when no root access March 22, 2006, 4:21 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap