我试图使用CommonMark C库和Inline::C创建一个简单的包装器。我已经在
我的当前代码如下:
/usr/local/lib/
下安装了libcmark.so
。我的当前代码如下:
package Text::CommonMark;
use strict;
use warnings;
sub commonmarker {
my $text = shift;
return commonmark_to_html($text);
}
use Inline C => qq{
char* commonmark_to_html(char* thetext) {
char* result = cmark_markdown_to_html(thetext, strlen(thetext));
return result;
}
} => LIBS => '-L/usr/local/lib/ -llibcmark.so';
1;
当我从一个脚本中使用commonmarker
时,我得到:
perl: symbol lookup error: /home/erik/sublimeworks/dists/Text-CommonMark/_Inline/lib/auto/Text/CommonMark_33fb/CommonMark_33fb.so: undefined symbol: cmark_markdown_to_html
我猜测我的调用与它的签名不匹配,但我在找到的所有的签名中,都是这样的:found
char *cmark_markdown_to_html(const char *text, int len)
我以前没有接触过C或Inline::C,所以可能会有所遗漏。
q{}
而不是qq{}
可以减少转义的次数。更好的方法是使用<<'EOC'
,这样你就不必转义任何东西了。 - ikegamiperl -MInline=force,info,noclean script.pl
可能会提供更多信息。 - ikegami