Perl XSPP - std::string 的多重定义
我正在尝试将一些 Google 网址库功能公开为 Perl 模块。根据此处和其他地方的一些帖子,看起来 XSPP 可能是一个好地方开始。这是我到目前为止创建的内容(从 googleurl lib 的编译版本开始):
我创建了这个 xspp 文件(为简洁起见,省略了一些方法):
#include "gurl.h"
%typemap{std::string};
%typemap{bool};
%module{Google::URL};
class GURL
{
%name{new} GURL(std::string& url);
~GURL();
bool is_valid();
bool is_empty();
std::string spec();
std::string possibly_invalid_spec();
std::string scheme();
std::string username();
std::string password();
std::string host();
std::string port();
std::string path();
std::string query();
std::string ref();
bool has_scheme();
bool has_username();
bool has_password();
bool has_host();
bool has_port();
bool has_path();
bool has_query();
bool has_ref();
};
我创建了这个 Makefile.PL 文件:
use 5.012;
use Module::Build::WithXSpp;
my $build = Module::Build::WithXSpp->new(
module_name => 'Google::URL::GURL',
license => 'perl',
extra_typemap_modules => {
'ExtUtils::Typemap::Default' => '0.01',
'ExtUtils::Typemap::STL' => '0.01',
},
extra_linker_flags => '-L../googleurl -lgoogleurl',
extra_compiler_flags => '-I. -I.. -I../googleurl -I../googleurl/base -I../googleurl/src',
);
然后我运行:
perl Makefile.PL && ./Build
.. 并得到以下错误:
WARNING: the following files are missing in your kit:
GURL.xs
Please inform the author.
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Google-URL-GURL' version '0.01'
Building Google-URL-GURL
Processing XS typemap files...
Multiple definition of ctype 'std::string' in TYPEMAP section at ~/lib/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/ExtUtils/Typemaps.pm line 819.
有 xspp 经验的人是否知道可能导致此错误的原因是什么?我可以在上面的 GURL.xsp 文件上成功运行 xspp,它会生成对我来说看起来合理的输出。
I'm attempting to expose some of the Google URL Library functionality as a perl module. Based on some posts here and elsewhere, it looks like XSPP might be a good place to start. Here's what I've created so far (starting with a compiled version of the googleurl lib):
I created this xspp file (some methods omitted for brevity):
#include "gurl.h"
%typemap{std::string};
%typemap{bool};
%module{Google::URL};
class GURL
{
%name{new} GURL(std::string& url);
~GURL();
bool is_valid();
bool is_empty();
std::string spec();
std::string possibly_invalid_spec();
std::string scheme();
std::string username();
std::string password();
std::string host();
std::string port();
std::string path();
std::string query();
std::string ref();
bool has_scheme();
bool has_username();
bool has_password();
bool has_host();
bool has_port();
bool has_path();
bool has_query();
bool has_ref();
};
And I created this Makefile.PL file:
use 5.012;
use Module::Build::WithXSpp;
my $build = Module::Build::WithXSpp->new(
module_name => 'Google::URL::GURL',
license => 'perl',
extra_typemap_modules => {
'ExtUtils::Typemap::Default' => '0.01',
'ExtUtils::Typemap::STL' => '0.01',
},
extra_linker_flags => '-L../googleurl -lgoogleurl',
extra_compiler_flags => '-I. -I.. -I../googleurl -I../googleurl/base -I../googleurl/src',
);
Then I run:
perl Makefile.PL && ./Build
..and get the following error:
WARNING: the following files are missing in your kit:
GURL.xs
Please inform the author.
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Google-URL-GURL' version '0.01'
Building Google-URL-GURL
Processing XS typemap files...
Multiple definition of ctype 'std::string' in TYPEMAP section at ~/lib/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/ExtUtils/Typemaps.pm line 819.
Does anyone with xspp experience have any idea what could be causing this error? I can successfully run xspp on my GURL.xsp file above and it produces output that looks reasonable to me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ExtUtils::Typemaps::Default 的文档清楚地表明它已经包括ExtUtils::Typemaps::STL。如果您从
extra_typemaps
中删除后者,它应该可以正常工作。The documentation of ExtUtils::Typemaps::Default clearly says it already includes ExtUtils::Typemaps::STL. If you remove the latter from your
extra_typemaps
, it should all work.