$ cargo run
Compiling a v0.1.0 (/home/*****/rust/a)
Finished dev [unoptimized + debuginfo] target(s) in 1.16s
Running `target/debug/a`
Hello, world!
实在不行卸载rust重装吧,我的就没有问题。
$ cargo run
Compiling a v0.1.0 (/home/*****/rust/a)
Finished dev [unoptimized + debuginfo] target(s) in 1.16s
Running `target/debug/a`
Hello, world!
实在不行卸载rust重装吧,我的就没有问题。
这个涉及到了,我的盲区!
不过你把没把内核换成6.1
Rust不是6.1以上支持吗?
加入深度内测,之后apt安装6.1内核,内测仓库有!
代码,Linux内核版本,rust版本,nightly还是stable,版本号多少,你先给说清楚啊。
$ cargo run
Compiling a v0.1.0 (/home/*****/rust/a)
Finished dev [unoptimized + debuginfo] target(s) in 1.16s
Running `target/debug/a`
Hello, world!
实在不行卸载rust重装吧,我的就没有问题。
你的内核和系统版本还有cmake,g++,gcc版本是多少,我参考一下,谢谢
这个涉及到了,我的盲区!
不过你把没把内核换成6.1
Rust不是6.1以上支持吗?
加入深度内测,之后apt安装6.1内核,内测仓库有!
不是的哦,你说的应该是rust进入linux内核构建的事。
我的deepin20.8就可以正常运行(虽然我不会rust编程)。
你的内核和系统版本还有cmake,g++,gcc版本是多少,我参考一下,谢谢
rustc和cargo用不上cmake,gcc,g++,你问这些还不如问glibc的版本,话说你试过切换rust的不同channel试试吗?
$ ls
Cargo.lock Cargo.toml src target
$ cat src/main.rs
fn main() {
println!("Hello, world!");
}
$ tree
.
├── Cargo.lock
├── Cargo.toml
├── src
│ └── main.rs
└── target
├── CACHEDIR.TAG
└── debug
├── a
├── a.d
├── build
├── deps
│ ├── a-5db37415f70d84cf
│ └── a-5db37415f70d84cf.d
├── examples
└── incremental
└── a-30mw4e3or7bor
├── s-gih0afe7ry-20lmu-kt7smmnlp3x6
│ ├── 2jee1n4ukur4ok5i.o
│ ├── 2jysz0emq293xez2.o
│ ├── 30gmizbdmcotdhvo.o
│ ├── 34t40cpjmmrj1yc9.o
│ ├── 3mozz82acb5bgczf.o
│ ├── 57ii8pfdql1zp61y.o
│ ├── dep-graph.bin
│ ├── query-cache.bin
│ └── work-products.bin
└── s-gih0afe7ry-20lmu.lock
9 directories, 18 files
$

什么hello-world,代码放出来看看?
或者加上环境变量 RUST_BACKTRACE=1 跑下看看报错

实在不行直接 rustup self uninstall(卸载rust的命令)开干。
然后再
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
安装。
代码,Linux内核版本,rust版本,nightly还是stable,版本号多少,你先给说清楚啊。
Rust版本:rustc 1.67.1 (d5a82bbd2 2023-02-07)
Cargo版本:cargo 1.67.1 (8ecd4f20a 2023-01-10)
deepin 社区版20.8
内核版本 5.15.77-amd64-desktop
编译器等相关版本:gcc (Uos 8.3.0.6-1+dde) 8.3.0, GNU ld (GNU Binutils for Uos) 2.31.1)
git version 2.20.1
cmake version 3.22.1
cc (Uos 8.3.0.3-3+rebuild) 8.3.0
ldd (Debian GLIBC 2.28.21-1+deepin-1) 2.28
rustc和cargo用不上cmake,gcc,g++,你问这些还不如问glibc的版本,话说你试过切换rust的不同channel试试吗?
你说的channel是源吗?.cargo/下config.toml的源是
#in .cargo/config
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-nostartfiles"]
[target.'cfg(target_os = "windows")']
rustflags = ["-C", "link-args=/ENTRY:_start /SUBSYSTEM:console"]
[target.'cfg(target_os = "macos")']
rustflags = ["-C", "link-args=-e __start -static -nostartfiles"]
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
所以代码呢?难道就一行println?初学者没挂在编译器静态检查,挂在内存访问错误?不信。
cargo build 结果输出下,还是不可告人?
rustc和cargo用不上cmake,gcc,g++,你问这些还不如问glibc的版本,话说你试过切换rust的不同channel试试吗?
fltk-rs好像得用上g++
所以代码呢?难道就一行println?初学者没挂在编译器静态检查,挂在内存访问错误?不信。
cargo build 结果输出下,还是不可告人?
源代码是
fn main() {
println!("Hello, world!");
}

所以代码呢?难道就一行println?初学者没挂在编译器静态检查,挂在内存访问错误?不信。
cargo build 结果输出下,还是不可告人?
绝对有道理,如果是一个 hello world 的程序不可能出现 “段错误”,绝对不可能的,段错误一定是非法访问内存。
你说的channel是源吗?.cargo/下config.toml的源是
#in .cargo/config
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-nostartfiles"]
[target.'cfg(target_os = "windows")']
rustflags = ["-C", "link-args=/ENTRY:_start /SUBSYSTEM:console"]
[target.'cfg(target_os = "macos")']
rustflags = ["-C", "link-args=-e __start -static -nostartfiles"]
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
是
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-nostartfiles"]
这行的问题,没链接startfiles,你是照着哪个大聪明复制的这个配置。。。
你把这行删了cargo clean一下在build就好了,你的上个帖子也是这个问题。。。
不是的哦,你说的应该是rust进入linux内核构建的事。
我的deepin20.8就可以正常运行(虽然我不会rust编程)。
哦哦哦,懂了!
😂😂😂
是
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-nostartfiles"]
这行的问题,没链接startfiles,你是照着哪个大聪明复制的这个配置。。。
你把这行删了cargo clean一下在build就好了,你的上个帖子也是这个问题。。。
好吧,竟然是改了编译参数……
结案了,初学者被坑事件。
是
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-nostartfiles"]
这行的问题,没链接startfiles,你是照着哪个大聪明复制的这个配置。。。
你把这行删了cargo clean一下在build就好了,你的上个帖子也是这个问题。。。
这段是什么意思? 当时好像网上找的复制下来的
Popular Events
More
【救救孩子!】Rust的Cargo 提示段错误,不知道错在哪里
只是一个很简单的hello world ,用rustc直接可以出,但是用cargo构建就出问题了
好烦,都搞好长时间了,连个hello world构建都出不来
===============================================
Rust版本:rustc 1.67.1 (d5a82bbd2 2023-02-07)
Cargo版本:cargo 1.67.1 (8ecd4f20a 2023-01-10)
deepin 社区版20.8
内核版本 5.15.77-amd64-desktop
编译器等相关版本:gcc (Uos 8.3.0.6-1+dde) 8.3.0, GNU ld (GNU Binutils for Uos) 2.31.1)
git version 2.20.1
cmake version 3.22.1
cc (Uos 8.3.0.3-3+rebuild) 8.3.0
ldd (Debian GLIBC 2.28.21-1+deepin-1) 2.28
===============================================================================
2022.02.22
终于找到问题了
在大佬的帮助下成功发现了原来罪魁祸首是这几行代码
/.cargo下的
config.toml 文件
删掉就OK了
心酸,找了这么久原来一切都是
"link-arg=-nostartfiles"]还以为是glibc,cmake,gcc,g++的版本太低的问题,搞到我还去学docker了,甚至想升级g++版本😂
千万千万不要在NTFS分区的源码里编译