Update:
I did finally get this to work correctly. The interp.c application didn't work before because I chose the wrong project type. Here's what you do to build it in MS Visual C++ 6:
(This is mostly taken from the perlembed document, but with slight modifications that helped me.)
- Run 'perl -MExtUtils::Embed -e xsinit' from the command line to generate the perlxsi.c file.
- Create a new "Win32 Console Application" project and name it interp. (If you select "Win32 Application", it won't build properly).
- Insert the following files into your project by selecting Projet -> Add To Project -> Files...:
- perlxsi.c
- perl56.lib (yes, actually insert it into the project)
- interp.c (the first example app from perlembed)
Typically you'll find perl.lib in C:\perl\lib\CORE, if not, you should see the CORE directory relative to perl -V:archlib.
The studio will also need this path so it knows where to find Perl include files. This path can be added via the Tools -> Options -> Directories tab.
- Finally, select Build -> Build interp.exe and you're ready to go.
The problems I originally ran into here were apparently just environment related. I am not a VC++ expert, so it took me a bit to figure it out. I was also able to build a Win32 Windows executable that works. Here's the steps involved to do that:
- Run 'perl -MExtUtils::Embed -e xsinit' from the command line to generate the perlxsi.c file.
- Rename perlxsi.c to perlxsi.cpp
- Create a new "MFC AppWizard (exe)" project and name it perldlg. Select "Dialog Based Application" and Finish.
- Copy perlxsi.cpp to your main project directory
- Insert the following files into your project by selecting Projet -> Add To Project -> Files...:
- Place the following line in the bottom of perldlgDlg.h:
static PerlInterpreter *my_perl;
- Add the following includes to the top of perldlgDlg.h:
#include <EXTERN.h>
#include <perl.h>
- Place the following code at the bottom of your perlxsi.cpp file. IT MUST BE PLACED AT THE BOTTOM OF THE FILE AFTER EVERYTHING ELSE OR IT WON'T BUILD.
#include "stdafx.h"
- Use the perl interpreter pointer declared earlier (*my_perl) in perldlgDlg.h to access perl functionality.
- Build perldlg.exe by selecting Build -> Build perldlg.exe
You may get some compiler warnings about EXTERN_C being redefined. I just removed the second definition. While this may not be desirable, it does allow the application to compile, link, and run.
Please understand that I am not certain as to why a lot of this was needed or how it all works, but I was successful in getting it to build. If you have questions, I'll do my best to help. Good luck!!
-Matt
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.