How can I call MFC functions from Perl

How can I call MFC functions from Perl

am 20.07.2005 06:46:37 von Sankaran

Hello,

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

Regards,
Sankaran

Re: How can I call MFC functions from Perl

am 20.07.2005 13:54:34 von Sisyphus

"Sankaran" wrote in message
news:1121834797.922460.149360@g44g2000cwa.googlegroups.com.. .
> 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

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

private:
COurWnd* GetMainWindow() {return static_cast(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

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