Click here to get back home

How can I call MFC functions 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
How can I call MFC functions from Perl Sankaran 07-19-2005
Posted by Sankaran on July 19, 2005, 9:46 pm
Please log in for more thread options


Hello,

How can I call MFC functions from Perl? Which module / method I should
select? Inline:C ? Inline:CPP ? XS ? or SWIG?

Regards,
Sankaran



Posted by Sisyphus on July 20, 2005, 9:54 pm
Please log in for more thread options



> Hello,
>
> How can I call MFC functions from Perl? Which module / method I should
> select? Inline:C ? Inline:CPP ? XS ? or SWIG?
>

If no-one here knows, ask on the Inline mailing list. The question seems to
have been raised on that list only once - and then not answered. But that
was some time ago and there might now be someone there who knows the answer.

I personally would not even attempt it with Inline::C - but Inline::CPP
could be worth trying if you've got it installed and functioning correctly.

I found the following code in a book and tried to compile it:

--- start SimpleMFCApp.cpp ----

#include <afxwin.h>

//Window class definition
class COurWnd : public CFrameWnd
{
};
// Application class definition
class COurApp : public CWinApp
{
public:
virtual BOOL InitInstance();

private:
COurWnd* GetMainWindow() {return static_cast<COurWnd*>(m_pMainWnd);}
};

//Function to create an instance of the main window
BOOL COurApp::InitInstance(void)
{
//Construct an object of our C++ window class
m_pMainWnd = new COurWnd;

//Call Create() to create the underlying window
GetMainWindow()->Create(NULL, _T("Our Simple Window"));

//Call ShowWindow() to display the window
GetMainWindow()->ShowWindow(m_nCmdShow);
return TRUE;
}

//Application object definition at global scope
COurApp AnApplication;

--- end SimpleMFCApp.cpp ----

But when I try to compile it I always get linking errors - no matter what I
try to link to. Closest I got to getting it to compile was by linking to
libcmt.lib with:

cl /MT SimpleMFCApp.cpp

That produced:

-----------------------------------
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.

SimpleMFCApp.cpp
Microsoft (R) Incremental Linker Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.

/out:SimpleMFCApp.exe
SimpleMFCApp.obj
libcmt.lib(crt0.obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup
SimpleMFCApp.exe : fatal error LNK1120: 1 unresolved externals
----------------------------------

Unfortunately the only advice I could find on google involved clicking on
options within the Visual Studio GUI - which just makes me wanna throw up. I
couldn't find any help in terms of command line options. Do you know how
that app could be compiled from the command line ?

Or am I supposed to build a dll rather than executable ? I did find that by
removing the last line of code from SimpleMFCApp.cpp I was able to build a
dll by running:

cl /LD SimpleMFCApp.cpp

Do you want to access (from perl) an MFC dll ? Is that what you are trying
to do ?

I spent half an hour or so trying to access my SimpleMFCApp.dll using
Inline::CPP, but could not get past the error:

F:\vsnet\Vc7\atlmfc\include\afxv_w32.h(18) : fatal error C1189: #error :
WINDOWS.H already included. MFC apps must not #include <windows.h>

I don't know why that's happening yet (not sure whether it's something I'm
doing, or whether it's something that Inline::C does - and I've run out of
time for tonight :-(


I don't know where one would ask (anything) about swig, but you might find
out something about the possibility of mixing MFC and XS from the perl-xs
mailing list. See http://lists.perl.org/index.cgi .

Cheers,
Rob





Similar ThreadsPosted
Module for Orchestrating Perl Functions? May 9, 2008, 9:30 pm
Calling External DLL functions in Perl using Inline July 11, 2005, 6:47 am
PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please. July 13, 2004, 4:06 am
Perl interface to direct port I/O functions (inb(), outb() and friends) February 19, 2005, 9:00 pm
Modules for hash functions? (ie, common algorithms for computing hash keys, not manipulating perl hashes) August 26, 2006, 7:08 pm
Win32::Ole and Call by reference October 22, 2004, 10:06 am
How to call PL/SQL procs using Oraperl ? December 8, 2004, 5:22 pm
Parsing XML data as it arrives from LWP call January 11, 2005, 1:57 am
System call fails in webserver February 11, 2006, 11:04 am
Can't call method on an undefined value at June 27, 2005, 2:56 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap