perl embeded into c++ 完全攻略

38 篇文章 1 订阅
24 篇文章 0 订阅

perl embeded into c++<script language="JavaScript" type="text/javascript"> document.title="perl embeded into c++ - "+document.title </script> 完全攻略

 

step 1:

要想在Microsoft Developer Studio中使用perl首先要运行:

perl -MextUtils::Embed -e xsinit

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

Step2:

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

Project->Win32 Consol Application-> an empty project

step3

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

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

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

Executable files
x:/perl/bin
Include files
x:/perl/lib/core
Library files
x:/perl/lib/core

Step4

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

static PerlInterpreter *my_perl;

int main(int argc, char **argv)
{
    char* command_line[] = {"", "-e","print /"Hello from C!//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);
    return 0;
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值