Mic*_*ich 5 c++ perl visual-studio
我有一个大约 15,000 行的 Perl 脚本,我想使用PerlInterpreter
C++ 编译的 Windows 可执行文件来执行该脚本。
我尝试按照这些指示进行操作
我下载了 Perl 5.18 源代码并包含核心(安装)目录, for perl.h
、 and EXTERN.h
、以及core/win32
andcore/win32/include
然后我尝试在 Visual Studio 2013 中编译简单的 C++ 项目
#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int main(int argc, char **argv, char **env)
{
PERL_SYS_INIT3(&argc,&argv,&env);
my_perl = perl_alloc();
perl_construct(my_perl);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
}
Run Code Online (Sandbox Code Playgroud)
该项目无法编译,出现数百个错误,但最常见的错误是
missing config.h file included by perl.h
Run Code Online (Sandbox Code Playgroud)
所以我添加了一条#define PERL_MICRO
声明perl.h
这将错误数量减少到 20 个
然而,所有错误都源自 Windows SDK 文件string.h
,guidedef.h
所以我不知道这些错误的根源是什么
任何人都可以向我提供有关如何为 Perl 脚本创建和构建 C++ 解释器的任何信息吗?
剩下的错误是
Error 10 error C3861: 'my_memcmp': identifier not found c:\program files (x86)\windows kits\8.1\include\shared\guiddef.h 161 1
Error 3 error C2733: 'memmove_s' : second C linkage of overloaded function not allowed c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 136 1
Error 4 error C2733: 'memmove' : second C linkage of overloaded function not allowed c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 139 1
Error 2 error C2733: 'memcpy_s' : second C linkage of overloaded function not allowed c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 57 1
Error 1 error C2733: 'memcpy' : second C linkage of overloaded function not allowed c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 55 1
Error 8 error C2732: linkage specification contradicts earlier specification for 'strstr' c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 228 1
Error 7 error C2732: linkage specification contradicts earlier specification for 'strrchr' c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 226 1
Error 6 error C2732: linkage specification contradicts earlier specification for 'strpbrk' c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 224 1
Error 5 error C2732: linkage specification contradicts earlier specification for 'strchr' c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 222 1
Error 9 error C2732: linkage specification contradicts earlier specification for 'memchr' c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h 233 1
Run Code Online (Sandbox Code Playgroud)
我将描述一些我所知道的关于这个主题的事情。我希望这个能帮上忙。
首先,您应该指定您在 Windows 上使用的 Perl。据我所知,Windows 上至少有 2 个:
其次,你想要实现的目标是Embedding a Perl interpreter in a C/C++ application
。我提到这一点是为了让您在搜索相关文档时可以参考它。
相关文档提供了有关此内容的一般信息。
如果您想在 Windows 上使用 ActivePerl 执行此操作,您可以查看Embedding Perl Under WIN32。
对于 Strawberry Perl,Perlmonks 上的某人在这里提供了一个在 Windows 上嵌入 Perl 的工作示例。
同时,请注意,遵循perlwin32 perl 文档页面可能会很有用,以便使用适当的路径设置 MSVC 编译器。
最后,还有一本关于该主题的书,名为《Extending and Embedding Perl》,您可能需要阅读该书以了解有关该主题的一些详细信息。在本书中,第 8 章一般性地讨论了在 C 中嵌入 Perl,第 9 章涉及嵌入案例研究。
更新:
阅读ExtUtils::MakeMaker
文档我发现这部分看起来很有趣:
If you are running experiments with embedding perl as a library into other applications, you might find MakeMaker is not sufficient. You'd better have a look at ExtUtils::Embed which is a collection of utilities for embedding.
特别是ExtUtils::Embed与Utilities for embedding Perl in C/C++ applications
.
我自己没有尝试过,但我认为它会有所帮助。一旦我有时间研究这个问题,我会回来提供更多细节。
更新:
具有嵌入式 Perl 解释器的应用程序列表:
ExtUtils::Embed
内部使用configure.in
(git clone git://git.irssi.org/irssi
详细信息请参见svn.irssi.org)ExtUtils::Embed
其 中使用configure.in
。了解更多详细信息hg clone https://vim.googlecode.com/hg/ vim
。Vim 还允许 通过 Perl 编写脚本。) 归档时间: |
|
查看次数: |
1956 次 |
最近记录: |