【发布时间】:2016-01-30 19:18:56
【问题描述】:
我正在尝试掌握 SWIG。现在,我无法为 perl 构建简单的模块。这是我所做的:
example.cpp:
#include <iostream>
void hello()
{
std::cout << "Hello, world!"<< std::endl;
}
example.i:
%module example
%{
#include <iostream>
extern void hello();
%}
extern void hello();
app.pl:
#!/usr/bin/perl
use strict;
use warnings;
use example;
example::hello();
还有我的compile.sh 脚本:
#!/bin/bash -ex
arch=`perl -e 'use Config; print $Config{archlib};'`
swig3.0 -c++ -perl5 example.i
g++ -fPIC -c example.cpp
g++ -fPIC -c example_wrap.cxx -I$arch/CORE -L$arch/CORE
g++ -shared example_wrap.o -o example.so
编译正常 - 没有显示错误。但是,当我运行 app.pl 时,出现以下错误:
/usr/bin/perl: symbol lookup error: ./example.so: undefined symbol: _Z5hellov
我尝试谷歌了一下,但无济于事。到目前为止,一切都失败了。我做错了什么?
我正在使用带有 3.13 内核和 perl 5.18.2 的 Linux Ubuntu x86_64
【问题讨论】: