gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 20:30:03 26 4
gpt4 key购买 nike

我正试图公开一些 Google URL Library作为 perl 模块的功能。根据此处和其他地方的一些帖子,它看起来像 XSPP可能是一个很好的起点。这是我到目前为止创建的内容(从 googleurl 库的编译版本开始):

我创建了这个 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,它会生成对我来说合理的输出。

最佳答案

ExtUtils::Typemaps::Default 的文档清楚地说它已经包括ExtUtils::Typemaps::STL .如果您从 extra_typemaps 中删除后者,它应该一切正常。

关于c++ - Perl XSPP - std::string 的多重定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8141054/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com