Hello, I'm an intermediate rust programmer. I've made no_std projects before, but now for whatever reason, the compiler won't link with libc properly. After searching, I initially thought this was because printf and various stdio functions were inlined by default and couldn't be detected, however this error also applies to any function in libc.
The code I am using is just a basic no_std program.
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[no_mangle]
pub fn mainCRTStartup() {
main()
}
#[no_mangle]
fn main() {
unsafe {
libc::printf("Hello!\n\0".as_ptr() as _);
let x = libc::malloc(32);
}
}
#[panic_handler]
fn panic_handler(info: &PanicInfo) -> ! {
loop{}
}
(Yes I know I should be changing the settings in the linker so I don't have to define mainCRTstartup, but this is just for demonstration purposes)
This is my cargo.toml
[package]
name = "no_std_test"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = { version = "0.2.137", default-features = false }
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
Attempting to compile gives these errors:
I've been trying to fix this for the past week so any help is appreciated!