Python调用Rust编译的共享库出现错误,pythonrust,Rust Code:#[
Python调用Rust编译的共享库出现错误,pythonrust,Rust Code:#[
Rust Code:
#[no_mangle]use std::thread;pub extern fn process() { let handles: Vec<_> = (0..10).map(|_| { thread::spawn(|| { let mut _x = 0; for _ in (0..5_000_001) { _x += 1 } }) }).collect(); for h in handles { h.join().ok().expect("Could not join a thread!"); }}
Cargo.toml:
[package]name = "embed"version = "0.1.0"authors = ["hustlibraco <hustlibraco@gmail.com>"][lib]name = "embed"crate-type = ["dylib"]
编译得到target/release/libembed.so共享库,然后我在此目录下面新建了一个python文件:
from ctypes import cdlllib = cdll.LoadLibrary("target/release/libembed.so")lib.process()print("done!")
执行报错:
-bash-4.2# python invoke.py Traceback (most recent call last): File "invoke.py", line 5, in <module> lib.process() File "/usr/lib64/python2.7/ctypes/__init__.py", line 373, in __getattr__ func = self.__getitem__(name) File "/usr/lib64/python2.7/ctypes/__init__.py", line 378, in __getitem__ func = self._FuncPtr((name_or_ordinal, self))AttributeError: target/release/libembed.so: undefined symbol: process
这是Rust官方教程给的例子,为什么我这里会执行出错呢?
编橙之家文章,
相关内容
- 第三方账号登录,没有验证码,后台如何防止被恶意
- 网页sessionStorage的内容,python如何获取?,,本纯金渣男
- 如何获取某个网站全部的(cdn服务器)地址?,获取cdn,如何
- 写自动注册程序,抓取验证码的地方卡壳了!!,抓取
- Flask Web开发 9.3节 角色验证 return self.role is not None and
- Python3.5中,open()不同模式如r、r+ 、w+、w、a、a+有何不同
- 按照flask Mega-tutorial教程运行的网站如何实现登陆?,
- 该学习Python2还是Python3版本呢?,python2python3,初学者都
- 学习Python有什么好的书籍推荐?,学习Python书籍,学习
- 学习Python编程语言难吗?,学习Python编程语言,很多初学
评论关闭