我正在尝试为这个库创建一个python绑定:
http://code.google.com/p/hosterslib/.
我正在使用swig,继承人是代码:
%module pyhosters
%{
#include "hosters/hosters.hpp"
%}
%include "hosters/hosters.hpp"
Run Code Online (Sandbox Code Playgroud)
我跑
swig -c ++ -python -o swig_wrap.cxx swig.i
我编译
g ++ -O2 -fPIC -shared -o _pyhosters.so swig_wrap.cxx
python-config --libs --cflags-lhosters -lcln -lhtmlcxxpkg-config libglog --libs --cflags-I/usr/include/python2.6 -Wall -Wextra
但是当我运行python并导入它时,我得到:
>>> import pyhosters
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "./pyhosters.py", line 7, in <module>
import _pyhosters
ImportError: ./_pyhosters.so: undefined symbol: _ZN7hosters11hostersLink7getLinkEi
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?
谢谢.
这是错误的名称:
hosters::hostersLink::getLink(int)
Run Code Online (Sandbox Code Playgroud)
确保您已定义该功能.
好的,我仔细看了0.6的主机.头文件声明了两种getLink方法:
std::string getLink(void);
std::string getLink(int n);
Run Code Online (Sandbox Code Playgroud)
但源文件只声明第一个:
std::string hostersLink::getLink(void) {return Link;}
Run Code Online (Sandbox Code Playgroud)
但SWIG正在为这两个功能创建包装器,这些功能可以解决问题.我建议做以下两件事之一:
std::string getLink(int n);方法,因为它未定义.std::string getLink(int n) { ... }| 归档时间: |
|
| 查看次数: |
4850 次 |
| 最近记录: |