Perl XSPP - std::string 的多重定义

发布于 2024-12-15 16:56:20 字数 2033 浏览 0 评论 0原文

我正在尝试将一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

待"谢繁草 2024-12-22 16:56:20

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文