I am developing my Rust project on Ubuntu 20.04.2 LTS 64bit. I have setup the project to compile for the host architecture (using cargo build) and to cross-compile for the target archicture of ARM 64bit (using cargo build --target=aarch64-unknown-linux-gnu). The project has been cross-compiling fine up until now. On the target hardware platform there are serial ports that the application will be interacting with so I have added the Serial Port crate to my project. The project still compiles fine for the Ubuntu host architecture but I can no longer get it to cross-compile for the aarch64 taget.
I have added the target to rustup:
$ rustup target list
...
aarch64-fuchsia
aarch64-linux-android
aarch64-pc-windows-msvc
aarch64-unknown-linux-gnu (installed)
aarch64-unknown-linux-musl
aarch64-unknown-none
aarch64-unknown-none-softfloat
...
And I have installed the toolchain to rustup:
$ rustup toolchain list
stable-aarch64-unknown-linux-gnu
stable-x86_64-unknown-linux-gnu (default)
When I run the cargo build command of cargo build --target=aarch64-unknown-linux-gnu I get the following error during compiling:
$ cargo build --target=aarch64-unknown-linux-gnu
Compiling libudev-sys v0.1.4
error: failed to run custom build command for `libudev-sys v0.1.4`
Caused by:
process didn't exit successfully: `/mnt/hgfs/trunk/src/application/target/debug/build/libudev-sys-c6234f1891f55461/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=LIBUDEV_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_gnu
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_gnu
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "pkg-config has not been configured to support cross-compilation.\n\n Install a sysroot for the target platform and configure it via\n PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a\n cross-compiling wrapper for pkg-config and set it via\n PKG_CONFIG environment variable."', /home/nocker/.cargo/registry/src/github.com-1ecc6299db9ec823/libudev-sys-0.1.4/build.rs:38:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
I have installed pkg-config and libudev-dev. From the terminal I can get this output to confirm that pkg-config is installed:
$ pkg-config --version
0.29.1
but when I try to check that libudev is installed I get an error response:
$ libudev
libudev: command not found
$ libudev-dev
libudev-dev: command not found
When I try to install libudev again I get:
$ sudo apt install libudev-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libudev-dev is already the newest version (245.4-4ubuntu3.4).
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
When I try to install libudev-sys I get:
$ sudo apt install libudev-sys
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libudev-sys
I'm suspecting the reason that I cannot cross-compile is because of libudev but cannot figure this out. I have been trying to research how to solve this issue for a few days now but no luck with a solution. Any assistance or direction will be greatly appreciated. TIA.
If you are not dependent on some extra features you can disable the default libudev feature. Adapt the Cargo.toml this way:
serialport = {version = "4.0.1", default-features = false}
See also the description here: https://crates.io/crates/serialport
Otherwise you have to install a sysroot or wrapper. But I was not able to figure out how to do this (the solution above works fine for me). The error message I got is a little bit more meaningful:
pkg-config has not been configured to support cross-compilation.
Install a sysroot for the target platform and configure it via
PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
cross-compiling wrapper for pkg-config and set it via PKG_CONFIG
environment variable.
Related
I am trying to achieve cross compilation in rust to the raspberry pi. However there was a linkage error while compiler:
error: linking with `cc` failed: exit status: 1
However for resolving that I have to download new linker and not use the default.
While doing so I checked the information of my raspberry system by using:
rustup show
Got the following result:
Default host: x86_64-unknown-linux-gnu
rustup home: /home/akumar/.rustup
installed targets for active toolchain
--------------------------------------
arm-unknown-linux-gnueabihf
armv7-unknown-linux-gnueabihf
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.64.0 (a55dd71d5 2022-09-19)
Now for resolving the issue I have to download the package using the following command:
sudo apt install gcc-armv7-unknown-linux-gnueabihf
but after running the command, I am getting the following error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gcc-armv7-unknown-linux-gnueabihf
Please try this:
sudo apt install gcc-arm-linux-gnueabihf
for build your rust project:
cargo build --target=armv7-unknown-linux-gnueabihf
Please check tool - cross: https://github.com/cross-rs/cross
Cross uses docker for build and makes libraries isolation.
I tried to create my first substrate chain. Create Your First Substrate Chain
But I got some error while compiling substrate.
failed to run custom build command for librocksdb-sys v6.11.4
Does anybody know how to fix this problem?
You need to install additional library:
sudo apt install clang should help.
sudo apt-get update
sudo apt install make clang pkg-config libssl-dev
This should do the trick.
Reference: https://github.com/paritytech/polkadot/issues/65
From #apopiak
Are you on Apple M1? If, so there are currently issues with building rocksdb there. See here an approach: vikiival.medium.com/run-substrate-on-apple-m1-a2699743fae8
Also others have reported needing to:
You need clone the rust-rocksdb repo and checkout the commit listed here: https://github.com/substrate-developer-hub/substrate-node-template/issues/122 then you can create a config.toml file in your .cargo folder in your home directory and add a path to that cloned repo
You had better update cargo to the nightly version and then try it.
If it keep in stuck error try comment commands, you may will need to study link.
#rustup component add --toolchain=nightly rust-src rustfmt
rustup target add wasm32-unknown-unknown
#apt-get install llvm clang linux-headers-"$(uname -r)" #
apt install llvm clang
cargo build --release
#cargo fix --allow-dirty #cargo fix --edition
#lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
#ldconfig --version
ldconfig (Ubuntu GLIBC 2.31-0ubuntu9.2) 2.31
#cargo --version
cargo 1.60.0-nightly (25fcb13 2022-02-01)
#rustc --version
rustc 1.60.0-nightly (f624427f8 2022-02-06)
#rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /root/.rustup
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-unknown-linux-gnu
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.60.0-nightly (f624427f8 2022-02-06)
#ArmanRiazi.blockchain#Substrate#Dr.GavinWood
For details:
Walk-Through/Substrate/NodeSetup
You need to update the to this version: "6.20.3"
checksum = "c309a9d2470844aceb9a4a098cf5286154d20596868b75a6b36357d2bb9ca25d"
am running on M1!
I'm facing the error failed to run custom build command for openssl-sys v0.9.60 while trying to build my rust program. Here are the main.rs and the Cargo.toml files.
main.rs
extern crate reqwest;
fn main() {
let mut resp = reqwest::get("http://www.governo.mg.gov.br/Institucional/Equipe").unwrap();
assert!(resp.status().is_success());
}
Cargo.toml
[package]
name = "get_sct"
version = "0.1.0"
authors = ["myname <myemail>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = "0.10.10"
I installed openssl locally (as suggested in this question), using:
git clone git://git.openssl.org/openssl.git
cd openssl
./config --openssldir=/usr/local/ssl
make
make test
sudo make install
Finally, I ran export OPENSSL_DIR="/usr/local/ssl"
I noted I already had a anaconda instalation of openssl which was in my default path. To change the default path of openssl to the github instalation I ran chmod -x MYPATH/anaconda3/bin/openssl and now which openssl returns /usr/local/bin/openssl.
I also have pkg-config installed (as suggested in this question). Running which pkg-config returns /usr/bin/pkg-config
However, when I run cargo run again the program print the same error message. Here is the entire error message:
> cargo run
Compiling openssl-sys v0.9.60
Compiling tokio v0.2.24
Compiling pin-project-internal v0.4.27
Compiling pin-project-internal v1.0.2
Compiling mime_guess v2.0.3
Compiling url v2.2.0
error: failed to run custom build command for `openssl-sys v0.9.60`
Caused by:
process didn't exit successfully: `/PACKAGEPATH/target/debug/build/openssl-sys-db18d493257de4f7/build-script-main` (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
cargo:rerun-if-env-changed=OPENSSL_DIR
OPENSSL_DIR = /usr/local/ssl
--- stderr
thread 'main' panicked at 'OpenSSL library directory does not exist: /usr/local/ssl/lib', /home/lucas/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.60/build/main.rs:66:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build faile
It looks like that rust is searching for ssl in /usr/local/ssl/lib. In fact, there is a /usr/local/ssl folder in my PC, but there is no lib there.
What am I doing wrong here? How can make my local installation of openssl work with rust correctly?
This solved the issue for me in Ubuntu:
sudo apt install libssl-dev
I have no experience with installing this myself but may be able to give some pointers.
First of all about your effort to install OpenSSL. After cloning the repository, you do not select any particular branch before configuring and making. This means that you are building the master branch, which is an evolving version of OpenSSL 3.0.0. This is not a supported version according to the crate's documentation. In order to build a supported version of OpenSSL, you will have to switch to some 1.1.1 branch or tag. Alternatively, you can download the 1.1.1 version from OpenSSL's download page.
That said, it does not seem necessary to install OpenSSL from source. Under the section Automatic, the documentation explains that the crate can deal with all kinds of typical OpenSSL installations. It may be easier for you to follow that, if possible in your case. If so, then you should unset the OPENSSL_DIR environment variable otherwise that will (continue to) override the crate's automatic mechanisms to find the OpenSSL installation.
If you still want to stick with the Manual configuration, then indeed you should use environment variables, and OPENSSL_DIR seems a convenient one. However, it does not mean the same thing as the openssldir parameter that you used in your configure command ./config --openssldir=/usr/local/ssl. To get the details, check out the meaning of that configuration parameter. In fact, the crate's meaning of OPENSSL_DIR corresponds to the --prefix setting (which you did not configure).
The problem you are running into now is that your OPENSSL_DIR variable points to your directory for OpenSSL configuration files, whereas the crate expects it to point to the top of the actual OpenSSL installation directory tree (which in your case seems to reside at /usr/local).
I used the following set of commands
sudo apt install pkg-config
sudo apt-get install libudev-dev
On fedora 36 I was getting error: failed to run custom build command for openssl-sys v0.9.77 when trying to install cargo-generate using cargo install cargo-generate
openssl-devel and pkg-config were already installed.
There was another complain below the main one:
Can't locate FindBin.pm in #INC (you may need to install the FindBin
module) (#INC contains: /usr/local/lib64/perl5/5.34
/usr/local/share/perl5/5.34 /usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at
./Configure line 15.
The solution was:
sudo dnf install perl
Surprisingly, perl was already installed but by running sudo dnf install perl "some additional perl stuff" got installed which resolved the issue!
run :
sudo apt install pkg-config
I used the following commands on Ubuntu on Windows:
sudo apt install libudev-dev
sudo apt install libssl-dev
this worked for me:
sudo apt install librust-openssl-sys-dev
I ran rust on Windows Subsystem for Linux (Ubuntu). The following commands have worked for me.
sudo apt install libssl-dev
sudo apt install pkg-config
Set variable openssl_dir to suitable PATH
I started tinkering with gnome-shell to kill time and I just can't get jhbuild to work! I followed all the instructions on the jhbuild guide on the gnome-shell wiki.
I got to the part where it says to run $ jhbuild sysdeps gnome-shell.
txjoe#superpotato:~$ jhbuild sysdeps gnome-shell
System installed packages which are new enough:
libvpx (vpx.pc, installed=1.4.0)
speex (speex.pc, required=1.2rc1, installed=1.2rc1)
ruby
libtool
libtool-ltdl
[...]
gmime (gmime-2.6.pc, required=2.6.6, installed=2.6.20)
docbook-xml
mtdev (mtdev.pc, required=1.1.1, installed=1.1.5)
Required packages:
System installed packages which are too old:
(none)
No matching system package installed:
libsystemd-journal (libsystemd-journal.pc, required=201)
libtiff
poppler (poppler-glib.pc, required=0.24.0)
Optional packages: (JHBuild will build the missing packages)
System installed packages which are too old:
libical (libical.pc, required=1.0.1, installed=1.0)
WebKit (webkit2gtk-4.0.pc, required=2.11.3, installed=2.8.5)
No matching system package installed:
I installed the following packages manually
libsystemd-dev
python-poppler
libtiff5
python-libtiff
And I got the same output when I ran the same command again.
I checked other answers here, nothing seems to work so far. Any tips?
You need to install the development packages. It is possible that you installed the runtime libraries, but those ones do not have the header files to compile a program.
The development libraries in Debian-based distributions end in -dev. Thus, installing libtiff5 is not enough, because it is the runtime library.
In your specific case, you must install libtiff5-dev, libpoppler-glib-dev, and libsystemd-dev.
Alternatively, you can try:
$ sudo apt-get build-dep gnome-shell
This command will install the development libraries required to build gnome-shell. At least, this might help to start with, and fix the particular issues/
I am trying to cross-compile cabal-install for ARM. It has come down to installing the prerequisite packages one-by-one. I was able to configure, build and install some of the packages by following this page:
How do I install dependencies when cross compiling haskell code?
Until I got to the network package where I got this error after ./Setup build:
Setup: The program hsc2hs is required but it could not be found
After this I added the
--with-hsc2hs=arm-unknown-linux-gnueabihf-hsc2hs
switch to my configure, but this time I ran into
/opt/ghc-cross-7.8.3/bin/arm-unknown-linux-gnueabihf-hsc2hs: line 29: /opt/ghc-cross-7.8.3/lib/arm-unknown-linux-gnueabihf-ghc-7.8.3/bin/hsc2hs: cannot execute binary file: Exec format error
Apparently my arm-unknown-linux-gnueabihf-hsc2hs tool is not running on my host. Why is this happening? And why, for instance, arm-unknown-linux-gnueabihf-ghc is working but not hsc2hs? And lastly, is there workaround for installing my original network package?