当前位置: 首页 > news >正文

社交网站模板下载建网站 教程

社交网站模板下载,建网站 教程,.vip域名做网站,扬中论坛最新提示#xff1a;文章写完后#xff0c;目录可以自动生成#xff0c;如何生成可参考右边的帮助文档 ubuntu20.04搭建RUST开发环境并与C语言交互 前言开战一、确认环境版本二、环境搭建三、hello world#xff01;四、跟c语言进行交互1.rust调用C静态库2.C调用rust库 总结参考… 提示文章写完后目录可以自动生成如何生成可参考右边的帮助文档 ubuntu20.04搭建RUST开发环境并与C语言交互 前言开战一、确认环境版本二、环境搭建三、hello world四、跟c语言进行交互1.rust调用C静态库2.C调用rust库 总结参考 前言 开始学习rust从网上扒资料搭建开发环境。后续再跟OpenHarmony-RISCV结合。 开战 一、确认环境版本 二、环境搭建 rootznvhwd:/home/ptg/rust# curl --proto ‘https’ --tlsv1.2 https://sh.rustup.rs -sSf | sh curl: (35) OpenSSL SSL_connect: 连接被对方重设 in connection to sh.rustup.rs:443 rootznvhwd:/home/ptg/rust# ls rootznvhwd:/home/ptg/rust# sudo apt-get install git 正在读取软件包列表… 完成 正在分析软件包的依赖关系树 正在读取状态信息… 完成 git 已经是最新版 (1:2.25.1-1ubuntu3.13)。 升级了 0 个软件包新安装了 0 个软件包要卸载 0 个软件包有 31 个软件包未被升级。 rootznvhwd:/home/ptg/rust# curl --proto ‘https’ --tlsv1.2 https://sh.rustup.rs -sSf | sh curl: (35) OpenSSL SSL_connect: 连接被对方重设 in connection to sh.rustup.rs:443 获取rustup安装脚本失败有资料说是没安装git导致但环境中实际有git。大概率还是本地虚拟机网络的问题。 经排查修改DNS即可Ubuntu修改DNS的方法 编辑 /etc/resolv.conf 文件 sudo vim /etc/resolv.conf加入以下代码 nameserver 114.114.114.114 nameserver 8.8.8.8 又遇新坑 不知道啥原因曲线救国了。 浏览器打开https://sh.rustup.rs直接下载到rustup-init.sh。然后“./”执行即可。 多灾多难。。 https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init 再次尝试下载rustup-init。然后“./”执行。 报错 error: error decoding response body: operation timed out 解决 RUSTUP_DIST_SERVER‘https://mirrors.ustc.edu.cn/rust-static’ RUSTUP_UPDATE_ROOT‘https://mirrors.ustc.edu.cn/rust-static/rustup’ 终于下完了引用环境变量环境变量已经默认写入到~/.bashrc source ~/.bashrc 试用cargo 搞定。 三、hello world rootznvhwd:/home/ptg/rust# cargo new myos Creating binary (application) myos package note: see more Cargo.toml keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html rootznvhwd:/home/ptg/rust# ls main.rs myos rustup-init rustup-init.sh rootznvhwd:/home/ptg/rust# cd myos rootznvhwd:/home/ptg/rust/myos# cargo run Compiling myos v0.1.0 (/home/ptg/rust/myos) Finished dev profile [unoptimized debuginfo] target(s) in 0.20s Running target/debug/myos Hello, world! rootznvhwd:/home/ptg/rust/myos# ls Cargo.lock Cargo.toml src target rootznvhwd:/home/ptg/rust/myos# rootznvhwd:/home/ptg/rust/myos# rootznvhwd:/home/ptg/rust/myos# cd src/ rootznvhwd:/home/ptg/rust/myos/src# ls main.rs rootznvhwd:/home/ptg/rust/myos/src# cat main.rs fn main() { println!(“Hello, world!”); } 执行上面的命令应该是直接下载了一个git项目。 四、跟c语言进行交互 在Rust中调用C语言的代码需要以下几个步骤 编写或获得C语言的代码。创建Rust的外部函数接口FFI。使用Rust的unsafe块调用C函数。 1.rust调用C静态库 参考 Rust调用C程序的实现步骤 编译得到一个C语言的静态库 /*swap.c*/ #include stdint.hint swap(int32_t* a, int32_t* b) {int32_t tmp *a;*a *b;*b tmp;return 0; }gcc -c swap.c ar rcs libswap.a swap.o 在Rust中创建一个外部函数接口来使用这个库。 Cargo.toml文件中添加一个build.rs脚本以及libc依赖 [package] name myos version 0.1.0 edition 2021 build build.rs[dependencies] libc 0.2[build-dependencies] cc 1.0 在build.rs脚本(笔者将其放在了项目根目录下)中告诉cargo如何构建C库 /*build.rs*/ extern crate cc;fn main() {cc::Build::new().file(swap.c).compile(libswap.a); }创建Rust的外部函数接口可以 修改hello rust的main.rs /*main.rs*/ extern crate libc;extern C {fn swap(a: *mut i32, b: *mut i32); }fn main() {println!!!!!!!!!!!(hello,rust!);let mut x 5;let mut y 10;unsafe{swap(mut x as *mut i32, mut y as *mut i32);}println!(x: {}, y: {}, x, y); }报错 warning: spurious network error (3 tries remaining): [35] SSL connecterror (Recv failure: Connection reset by peer) warning: spuriousnetwork error (3 tries remaining): [28] Timeout was reached 应该还是网络的问题。。 尝试wget 对应文件SSL问题。 查了半天终于找到了解决方法 rootznvhwd:/home/ptg/rust/myos# cd ~/.cargo rootznvhwd:~/.cargo# ls bin config env registry rootznvhwd:~/.cargo# cat config [http] check-revoke false rootznvhwd:~/.cargo# rootznvhwd:/home/ptg/rust/myos# cd ~/.cargo rootznvhwd:~/.cargo# ls bin config env registry rootznvhwd:~/.cargo# cat config [http] check-revoke false rootznvhwd:~/.cargo# vim config 修改配置文件应该是换了源 [http] check-revoke false [source.crates-io] replace-with ustc [source.ustc] registry https://mirrors.ustc.edu.cn/crates.io-index终于搞定了。 2.C调用rust库 参考 C语言和Rust语言的互相调用(1)C调用Rust 总结 没啥 找资料照做遇到问题解决问题即可。 参考 https://zhaoseaside.blog.csdn.net/article/details/134484039 https://blog.csdn.net/fittec/article/details/137204059 https://zhuanlan.zhihu.com/p/687515644 https://www.jb51.net/program/307143aaq.htm https://blog.csdn.net/phthon1997/article/details/126469708
http://www.w-s-a.com/news/723572/

相关文章:

  • 新公司注册网站传奇手游大型网站
  • 无极网站网站涉案多少人被抓网站的按钮怎么做
  • ds216j做网站做购物网站那个好
  • 做淘宝门头的网站阿里巴巴官网app
  • 安踏网站建设策划方案如何通过域名访问网站
  • 建设网站破解版seo查询 站长之家
  • 太原模板建站平台旅游企业网站建设工作的通知
  • 网站国外建设超级简历模板官网
  • 上海网站建设市场医药网站怎么做
  • 宁夏成城建设集团网站网店美工课本
  • 哪些网站的简历做的比较好政务服务 网站 建设方案
  • 如何建设个人网站凡科怎么样vps安装wordpress后怎样登录
  • 学seo朝阳区seo
  • 网站开发团队成员皮具网站建设
  • 国外外贸需求网站响应式布局网页
  • 手机端便民服务平台网站建设昆明网络哪家好
  • 产品网站建设找哪家舟山信息港
  • 唐山网站建设汉狮怎么样seol英文啥意思
  • 深圳小程序网站开发公司网页制作模板视频教程
  • 电子商务网站开发开题报告wordpress更改后台地址
  • 网站静态前端是什么工作
  • 餐饮门户网站 方案怎么做创业好项目
  • 做百度手机网站推广普通话的宣传标语
  • 记事本可以做网站吗网站服务器是主机吗
  • 手机网站被拦截怎么办怎么解决东营建设信息网网
  • 外贸网站模板免费微信网站开发技术
  • 视频盗版网站怎么做福州网站seo
  • 成都金铭 网站建设做网站包含的技术
  • 长沙的网站建设公司哪家好做网站应选那个主题
  • 公司网站百度搜不到如何自己做一个网站