perl embeded into c++ 完全攻略

perl embeded into c++ document.title="perl embeded into c++ - "+document.title 完全攻略

step 1:

要想在MicrosoftDeveloperStudio中使用perl首先要运行:

perl-MextUtils::Embed-exsinit

生成perlxsi.c(perlxsi.cpp)文件.

Step2:

创建工程,选中创建空白工程的选项,再添加自己的源代码,这样产生的工程不会有多余的文件,默认也不使用预编译头。

Project->Win32ConsolApplication-> an empty project

step3

然后在生成的vc工程中将perlxsi.cperl.lib文件添加到SourceFiles文件夹中,这里注意perl.lib根据版本的不同也有不同,要到安装perl的文件夹下perl\lib\core中具体查找,比如我的就是perl58.lib

具体做法: VC打开时,这样添加project->Add to project->Files

除此之外,还要在vc的工具-〉选项-〉目录中将相关的库文件添加进来,我是这样设的:

Executablefiles
x:\perl\bin
Includefiles
x:\perl\lib\core
Libraryfiles
x:\perl\lib\core

Step4

测试程序如下
#include"EXTERN.h"
#include"perl.h"

staticPerlInterpreter*my_perl;

intmain(intargc,char**argv)
{
char*command_line[]={"","-e","print\"HellofromC!\\n\";"};

my_perl=perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl,NULL,3,command_line,(char**)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
return0;
}

你可能感兴趣的:(C++,c,C#,perl,vc++)