OrangePI使用 Rust-python 完整教程

首先要在目标机(OrangePI)上安装samba软件:

1:sudo apt-get update

2.sudo apt-get install samba samba-common-bin -y

3.安装完成后修改配置文件:

sudo gedit /etc/samba/smb.conf

在文件末尾添加:

[root]

workgroup = root

security = root

netbios name = root

comment = root

path = /

browsable = yes

writeable = yes

read only = no

保存退出:

4.增加samba用户:sudo smbpasswd -a root输入两次密码。

5.重启服务 :sudo /etc/init.d/samba restart

6.如果主机使用Linux,需要安装smbclient安装:

sudo apt-get install smbclient

7 查看目录的所有共享目录

    smbclient -L 10.0.0.11 # 10.0.0.11是samba服务器IP

8连接共享目录

smbclient //10.0.0.11/root # IP地址后接共享目录

9挂载共享目录到本地:

mount -t cifs -o username=xxx,password=xxx //10.0.0.11/root /home/zhangchengfei/tmp# 后面的是挂载目录

10.在主机安装rust:

$ curl https://sh.rustup.rs -sSf | sh

11.安装交叉编译器:

$ sudo apt-get install gcc-arm-linux-gnueabihf

12添加编译器到rust 中

$ rustup target add armv7-unknown-linux-gnueabihf

13添加环境变量

$ mkdir -p ~/.cargo $ cat >>~/.cargo/config <<EOF > [target.armv7-unknown-linux-gnueabihf] > linker = "arm-linux-gnueabihf-gcc" > EOF

14 安装PYTHON支持:

sudo apt install python3-dev python-dev

15创建文件并进行交叉编译:

$ cargo new --bin hello $ cd hello/src

$ del main.rs

$gedit lib.rs

use pyo3::prelude::*;

//use std::f32::consts::PI;

use pyo3::wrap_pyfunction;

#[pyfunction]

fn hello() -> PyResult<()> {

println!("Hello,Rust!");

Ok(())

}

#[pymodule]

fn r2p(_py: Python, m: &PyModule) -> PyResult<()> {

m.add_wrapped(wrap_pyfunction!( hello ))?;

Ok(())

} $ cargo build --target=armv7-unknown-linux-gnueabihf 之后会在target/armv7-unknown-linux-gnueabihf 目录下生成libr2p.so

16 把文件名改成模块名:r2p.so,并把文件复制到目标机器上运行即可.

到此已经顺利在OrangePI上运行Rust  Python!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值