请选择 进入手机版 | 继续访问电脑版

中标麒麟V10上 rust代码依赖libc时的编译问题

编译器工具链 编译器工具链 1504 人阅读 | 1 人回复 | 2022-01-25

问题:可以编译常规rust代码,但依赖libc的代码编译失败,提示找不到c_char类型,求大佬支招。
  1. error[E0412]: cannot find type `c_char` in the crate root
  2.     --> src/unix/linux_like/linux/mod.rs:2879:36
  3.      |
  4. 2879 |     pub fn swapoff(puath: *const ::c_char) -> ::c_int;
  5.      |                                    ^^^^^^ help: a type alias with a similar name exists: `c_schar`
复制代码

系统环境:中标麒麟系统v10
编译器:按照此连接,安装的rust 1.34.2 版本(https://developer.wxiat.com/understand/ecologial/10

个人理解:cargo编译rust代码时,从github拉取对应版本的libc源码(https://github.com/rust-lang/libc),此源码中不包含sw_64相应的实现,所以无法编译通过??

其他信息:我在/usr/local/lib/rustlib/sw_64-sunway-linux-gnu/lib/目录下找到了libc的rlib文件
  1. [root@root]# ll /usr/local/lib/rustlib/sw_64-sunway-linux-gnu/lib/liblibc-*
  2. -rw-r--r-- 1 root root 1975726  1月 25 03:40 /usr/local/lib/rustlib/sw_64-sunway-linux-gnu/lib/liblibc-13210165ac4b5f51.rlib
  3. -rw-r--r-- 1 root root 1978762  1月 25 03:40 /usr/local/lib/rustlib/sw_64-sunway-linux-gnu/lib/liblibc-6acea21120fed0ed.rlib
复制代码









回复

使用道具 举报

回答|共 1 个

TecSupport

发表于 2022-3-7 14:09:25 | 显示全部楼层

申威平台有自己的libc库,直接从GitHub下载的源码,没有sw_64平台分支
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则