How can I call MFC functions from Perl

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


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


Re: How can I call MFC functions from Perl

Quoted text here. Click to load it

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
 virtual BOOL InitInstance();

 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
 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.

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

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 .


Site Timeline