Compiling rust with cpal for raspberry pi - rust

Ok so all I want to do is write an audio application for my raspberry pi. When I compiled a simple "hello world" for raspberry everything worked great but when i introduced cpal as a dependency i got this error after
cargo build --target=armv7-unknown-linux-gnueabihf
error: failed to run custom build command for `alsa-sys v0.1.2`
Caused by:
process didn't exit successfully: `/home/kuba/Projects/effect-box/hello-pi/target/debug/build/alsa-sys-967340f82a5fa569/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override"', src/libcore/result.rs:1084:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed
Its been a week and I got nothing. I feel like I've tried everything.
What couses this error and how can I fix it?
Background info: my os is elementary os (it is based on ubuntu so most things that work on ubuntu should work here too) and the code i'm trying to compile is this:
use cpal::traits::{DeviceTrait, HostTrait};
fn main() {
let host = cpal::default_host();
let device = host
.default_output_device()
.expect("no default output device");
let format = device
.default_output_format()
.expect("failed to get device name");
println!("{:?}", format);
println!("Hello, world!");
}
EDIT:
Thanks to Victor Deleau I added an enviroment variable PKG_CONFIG_ALLOW_CROSS=1. Now I'm getting this message:
error: linking with `cc` failed: exit code: 1
followed by this huge error https://pastebin.com/raw/ghHgpesV

Related

failed to run custom build command for `yeslogic-fontconfig-sys v3.2.0`

I am trying to learn how to plot in Rust and found a guide that is using plotters (if anyone knows a better plotting library let me know.)
https://plotters-rs.github.io/book/intro/getting_started.html
Anyways, I am on Fedora 37 and running into an issue using the example shown in the Getting started section of this guide.
The code is:
/*
Example of plotting in Rust
*/
use plotters::prelude::*;
fn main() {
let root_drawing_area = BitMapBackend::new("0.1.png", (1024, 768))
.into_drawing_area();
root_drawing_area.fill(&WHITE).unwrap();
let mut chart = ChartBuilder::on(&root_drawing_area)
.build_cartesian_2d(-3.14..3.14, -1.2..1.2)
.unwrap();
chart.draw_series(LineSeries::new(
(-314..314).map(|x| x as f64 / 100.0)
.map(|x| (x, x.sin())), &RED))
.unwrap();
}
In my cargo.toml file I've added the dependency using cargo add plotters
But when I run the code with cargo build I get this error:
Compiling yeslogic-fontconfig-sys v3.2.0
error: failed to run custom build command for `yeslogic-fontconfig-sys v3.2.0`
Caused by:
process didn't exit successfully: `/home/usr/Dev/RustyKrab/plotting/plot_example/target/debug/build/yeslogic-fontconfig-sys-3bf9e95194fbfdbd/build-script-build` (exit status: 101)
And goes on for stdout
--- stdout
cargo:rerun-if-env-changed=RUST_FONTCONFIG_DLOPEN
cargo:rerun-if-env-changed=FONTCONFIG_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=FONTCONFIG_STATIC
cargo:rerun-if-env-changed=FONTCONFIG_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
and stderr
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "`\"pkg-config\" \"--libs\" \"--cflags\" \"fontconfig\"` did not exit successfully: exit status: 1\nerror: could not find system library 'fontconfig' required by the 'yeslogic-fontconfig-sys' crate\n\n--- stderr\nPackage fontconfig was not found in the pkg-config search path.\nPerhaps you should add the directory containing `fontconfig.pc'\nto the PKG_CONFIG_PATH environment variable\nPackage 'fontconfig', required by 'virtual:world', not found\n"', /home/usr/.cargo/registry/src/github.com-1ecc6299db9ec823/yeslogic-fontconfig-sys-3.2.0/build.rs:8:48
With the last line of the error being note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
I've tried running RUST_BACKTRACE=1RUST_BACKTRACE=1 alacritty but simply just doesn't work.
How can I work around this so I can use plotters in Rust?
Note: I've installed fontconfig with sudo dnf install fontconfig

EclipseCDT will not debug executable: Error creating process

I just installed EclipseCDT 2022-12, created the HelloWorld example app, compiled, but when I debug I get an error. I have both current MSYS2 (MinGW64) and Cygwin64 installed, neither environment works and fails with the same error:
Error in final launch sequence:
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Error creating process /cygdrive/c/Windows/system32/C:/Projects/cc3135/hello/C:/Projects/cc3135/hello/Debug/hello.exe, (error 2).
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Error creating process /cygdrive/c/Windows/system32/C:/Projects/cc3135/hello/C:/Projects/cc3135/hello/Debug/hello.exe, (error 2).
Error creating process /cygdrive/c/Windows/system32/C:/Projects/cc3135/hello/C:/Projects/cc3135/hello/Debug/hello.exe, (error 2).
Any suggestions?
P.S. The hello executable runs fine in cmd.exe and under gdb.

Compiling error in rust: failed to run custom build command

I don't quite know what I am looking at, I'm quite certain that this is not my fault
PS C:\Users\alexa\Documents\UNIVERSITEIT\2_MASTER\DECISION MAKING FOR BUSINESS\CASE_E\shift_scheduling_code> cargo run
Compiling num-traits v0.2.15
Compiling num-integer v0.1.45
error: failed to run custom build command for `num-traits v0.2.15`
Caused by:
process didn't exit successfully: `C:\Users\alexa\Documents\UNIVERSITEIT\2_MASTER\DECISION MAKING FOR BUSINESS\CASE_E\shift_scheduling_code\target\debug\build\num-traits-0ab924901b158460\build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Other("output path is not a writable directory") }', C:\Users\alexa\.cargo\registry\src\github.com-1ecc6299db9ec823\autocfg-1.1.0\src\lib.rs:128:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `num-integer v0.1.45`
Caused by:
process didn't exit successfully: `C:\Users\alexa\Documents\UNIVERSITEIT\2_MASTER\DECISION MAKING FOR BUSINESS\CASE_E\shift_scheduling_code\target\debug\build\num-integer-7dbeca75e83a8205\build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Other("output path is not a writable directory") }', C:\Users\alexa\.cargo\registry\src\github.com-1ecc6299db9ec823\autocfg-1.1.0\src\lib.rs:128:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
PS C:\Users\alexa\Documents\UNIVERSITEIT\2_MASTER\DECISION MAKING FOR BUSINESS\CASE_E\shift_scheduling_code>
I don't really know where to begin solving this problem

How to fix Terra Rust Smart Contract OpenSSL Error

I am on windows 11. When i run "cargo install cargo-generate --features vendored-openssl" in cmd or powershell i receive:
error: failed to run custom build command for `openssl-sys v0.9.72`
Caused by:
process didn't exit successfully: `C:\Users\tjblu\AppData\Local\Temp\cargo-installsZBq7g\release\build\openssl-sys-dce3228ef73e702e\build-script-main` (exit code: 101)
\--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
running "perl" "./Configure" "--prefix=C:\\Users\\tjblu\\AppData\\Local\\Temp\\cargo-installsZBq7g\\release\\build\\openssl-sys-5dd3ef493eeba8e5\\out\\openssl-build\\install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-engine" "no-asm" "VC-WIN64A"
\--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: NotFound, message: "program not found" }', C:\\Users\\tjblu.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\openssl-src-111.18.0+1.1.1n\\src\\lib.rs:477:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-generate v0.13.0`, intermediate artifacts can be found at `C:\Users\tjblu\AppData\Local\Temp\cargo-installsZBq7g`
Caused by:
build failed
I've tried so many remedies, please help!
Tried installing perl, choco install openssl. Anything i could find online.
I have found a temporary workaround for this.
These are the steps I took:
Manually downloaded the 'cargo-generate' package from the following link: https://github.com/cargo-generate/cargo-generate/releases
Downloaded 'cargo-generate-v0.13.0-x86_64-pc-windows-msvc.tar.gz'
Extracted the content, and copied 'cargo-generate.exe' to the following Windows local directory path 'C:\Users\[username]\.cargo\bin\'.
Hope this helps for now, also waiting for a better solution.

Debug error when debugging OpenGL program remotely

I can use gdb to debug my OpenGL program on the server locally. But when I Debug it remotely. some errors come out in glutCreateWindow() function. And I can run my program remotely. Just can't debug .
freeglut (/home/fshen/samuel/project_self/GLSL-learning/teapotshader/teapotshader):
ERROR: Internal error <FBConfig with necessary capabilities not found> in
function fgOpenWindow
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 4 (X_DestroyWindow)
Resource id in failed request: 0x0
Serial number of failed request: 20
Current serial number in output stream: 23
PS:
First I can't run my program remotely. After setting export LIBGL_ALWAYS_INDIRECT=yes (I put this command in .bash_profile),I can run my project. Just can't debug it remotely. So I think i should add export LIBGL_ALWAYS_INDIRECT=yes into the GDB. But I don't know howto do it?

Resources