我正在尝试使用大众实时(RTFM) crate为STM32F4Discovery编写一个多线程裸机应用程序。我已经从example为STM32F3Discovery板和this example编写了一个最小的应用程序
#![deny(unsafe_code)]
#![no_main]
#![no_std]
extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
extern crate cortex_m_semihosting;
extern crate panic_semihosting;
extern crate stm32f4;
use stm32f4::stm32f407;
use rtfm::app;
app! {
device: stm32f407,
}
fn init(_p: init::Peripherals) {
}
fn idle() -> ! {
loop {
rtfm::wfi();
}
}我可以编译它,但是使用rust-lld链接失败
= note: rust-lld: error: undefined symbol: main我很困惑,因为当我运行cargo expand时,我确实得到了一个主函数:
fn main() {
#![allow(path_statements)]
let init: fn(init::Peripherals) = init;
rtfm::atomic(unsafe { &mut rtfm::Threshold::new(0) },
|_t|
unsafe {
let _late_resources =
init(init::Peripherals{core:
::stm32f407::CorePeripherals::steal(),
device:
::stm32f407::Peripherals::steal(),});
});
let idle: fn() -> ! = idle;
idle();
}我是Rust的新手(事实上,我希望通过这个项目学习该语言),并且不知道错误可能在哪里。
发布于 2018-09-20 22:04:37
当您要求编译器不要插入main时,您的程序中没有主符号。
main使用符号损坏,因此您的Rust函数不会有一个名为Rust的符号。
答案取决于您的上下文,但通常应该是这样的:
#[no_mangle] // ensure that this symbol is called `main` in the output
pub extern fn main(argc: i32, argv: *const *const u8) -> i32 {
}所有其他信息都可以在here上找到。
https://stackoverflow.com/questions/52425667
复制相似问题