Python中文
首页
教程
问答
标签
搜索
登录
注册
SWIG Python未定义的symb
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在尝试使用SWIG创建一个*.so文件,以便在Python中进一步使用,但是有些东西不起作用。</p> <p>我有两个文件: 数据采集器</p> <pre class="lang-cpp prettyprint-override"><code>#include <iostream> #include <stdlib.h> #include <time.h> #include "gnublin.h" #include <pthread.h> class dataGatherer { private: int threshold; int timeThreshold; int data[4096]; bool running; gnublin_spi* spiDevice; pthread_t spiThread; void *params; public: dataGatherer(void); dataGatherer(int, int); void initData(); int getThreshold(void); int* getData(void); int getPeak(void); void initSPI(void); void gatherData(); void * run(void * arg); void stop(void); // for use of thread we have to implement some methods from C static void * start_static(void * params) { dataGatherer * thread_this = static_cast<dataGatherer*>(params); return thread_this->run(thread_this->params); } void start(void * params) { this->params = params; pthread_create(&spiThread, 0, &dataGatherer::start_static, this); } }; </code></pre> <p>和spiController.h</p> <pre class="lang-cpp prettyprint-override"><code>#include "dataGatherer.h" class spiController { private: bool runGather; dataGatherer* gatherer; int data[4096]; public: spiController(void); spiController(int, int); void initData(); bool checkStop(); void stop(); void start(); }; </code></pre> <p>我的spiController.i接口文件如下所示:</p> <pre><code>/* spiController.i */ %module spiController %{ #include "dataGatherer.h" #include "spiController.h" #include "gnublin.h" #include <stdlib.h> #include <time.h> #include <pthread.h> extern void initData(); extern bool checkStop(); extern void stop(); extern void start(); %} extern void initData(); extern bool checkStop(); extern void stop(); extern void start(); </code></pre> <p>最后,我尝试使用终端中的命令创建*.so文件,如SWIG页面上的示例:</p> <pre><code>swig -python -c++ spiController.i c++ -c spiController_wrap.c -I/usr/include/python2.7 c++ -shared spiController_wrap.o -o _spiController.so </code></pre> <p>*.cxx、*.o和*.so文件的创建没有错误,但是当我将spiController导入到python代码中时,我得到:</p> <pre><code>Traceback (most recent call last): File "<stdin>", line 1, in <module> File "spiController.py", line 26, in <module> _spiController = swig_import_helper() File "spiController.py", line 22, in swig_import_helper _mod = imp.load_module('_spiController', fp, pathname, description) ImportError: ./_spiController.so: undefined symbol: _Z9checkStopv </code></pre> <p>这是我第一次尝试使用SWIG,我已经陷入了困境。我该怎么解决?</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>您必须链接定义您已经声明为^ ^(CD<1}})的C++函数的库。您将在示例的编译步骤的第三行添加^ {< CD2>}。</p> <p>像这样:</p> <pre><code>c++ -L<path to DLL> -l<name of your dll> -shared spiController_wrap.o -o _spiController.so </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在python中从数据帧列中删除分类值?
2 回答
如何在python中从数据帧列表中删除引号
9 回答
如何在python中从数据帧创建列表
9 回答
如何在Python中从数据帧创建嵌套的JSON
10 回答
如何在Python中从数据帧显示wordcloud
9 回答
如何在Python中从数据帧的时间戳中删除字符
4 回答
如何在Python中从数据帧绘制简单绘图?
5 回答
如何在python中从数据帧行提取具有特定长度的范围?
3 回答
如何在python中从数据帧设置dict中的值
9 回答
如何在Python中从数据库中获得一个结果
8 回答
如何在python中从数据框中绘制分类条形图
7 回答
如何在Python中从数据框中选择特定细节?
8 回答
如何在python中从数据集中删除unicode
7 回答
如何在python中从数据集中删除某些数值?
10 回答
如何在python中从数据集中选择行
10 回答
如何在Python中从数组中删除元素
2 回答
如何在python中从数组中删除单个倒逗号?
2 回答
如何在python中从数组中删除对象?
3 回答
如何在python中从数组中删除引号
3 回答
如何在python中从数组中删除所有最小值
4 回答