rust-num / num-complex

Complex numbers for Rust
Apache License 2.0
231 stars 47 forks source link

Problems compiling complex numbers on embedded target #115

Closed joakim-hove closed 1 year ago

joakim-hove commented 1 year ago

Hello;

I am creating software to run on a ARM microcontroller, when try to compile the following small program for the embedded target I get multiple compilation errors:

use num_complex::Complex;

fn main() {
    let z = Complex::<f32>::new(-1.0, 0.0);
    let _i = z.sqrt();
}

I build with:

bash% cargo build --target=thumbv7em-none-eabihf

and get a large error message from the compiler: debug.txt. In order to reproduce you must install the thumbv7em-none-eabihf target with:

bash% rustup target add thumbv7em-none-eabihf

NB: When compiling for the default host target with cargo build everything works as a charm.

Update: The errors all seem to stem from the implementation of the num-traits trait, and using e.g. the num_integer instead of num_complex I get the same error messages; so maybe the num-traits repository is a more suitable place for this issue?

joakim-hove commented 1 year ago

OK - I found a solution: disable default features and explicitly use the libm crate when declaring the num_complexdependency:

[dependencies.num-complex]
version = "0.4.3"
default-features = false
features = ["libm"]