As part of one of my projects, I have to cross-compile a Rust crate from x86_64 to i686 on Linux. I'm currently using Travis CI for this, with a simple Hello World crate (the default binary crate). My Travis CI configuration for the relevant matrix entry is:
# ...
matrix:
include:
# ...
- os: linux
rust: 1.30.0
before_script:
- sudo apt-get update
- sudo apt-get install -y libc6-dev:i386
env: TARGET=i686-unknown-linux-gnu
# ...
script:
- rustup target install $TARGET
- cargo build --release --target=$TARGET
Unfortunately, when I push this configuration to Travis CI, I get a build error:
$ cargo build --release --target=$TARGET
Compiling test-rust-deploy-releases v0.1.0 (/home/travis/build/arnavb/test-rust-deploy-releases)
error: linker `cc` not found
|
= note: No such file or directory (os error 2)
error: aborting due to previous error
error: Could not compile `test-rust-deploy-releases`.
To learn more, run the command again with --verbose.
The command "cargo build --release --target=$TARGET" exited with 101.
How do I fix this?
Well, after experimenting and more googling, I changed my apt install command to:
sudo apt-get install -y gcc-4.8 cpp-4.8 gcc-multilib
(The first two are unmet dependencies of the third, which had to be manually installed).
Now the build runs properly.
Related
I wanted to put together a Rust toolchain using the system package manager rather than downloading the rustup installer, and cross-compile for a Raspberry Pi 3
To that end, in Ubuntu 20.04 I have installed rustc and gcc-arm-linux-gnueabihf.
However, the cargo build --bins --release --target armv7-unknown-linux-gnueabihf command fails with
error[E0463]: can't find crate for `core`
|
= note: the `armv7-unknown-linux-gnueabihf` target may not be installed
Is there a way to get this working, other than curl https://sh.rustup.rs -sSf | sh && rustup target add arm-unknown-linux-gnueabihf?
Chances are that you are better off using a docker image to help.
I found this in general:
https://kerkour.com/rust-reproducible-cross-compilation-with-docker/
and, for armv7 I'd say something akin to:
apt update && apt upgrade -y
apt install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross
rustup target add armv7-unknown-linux-gnueabihf
rustup toolchain install stable-armv7-unknown-linux-gnueabihf
under Ubuntu should do the trick.
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'm trying to install a Rust crate on my system (Arch Linux) using Cargo. I can search for crates and find what I need, for example:
$ cargo search curl | head -n3
Updating registry `https://github.com/rust-lang/crates.io-index`
curl (0.3.0) Rust bindings to libcurl for making HTTP requests
curl-sys (0.2.0) Native bindings to the libcurl library
When I try to install it, I get the following error:
$ cargo install curl
Updating registry `https://github.com/rust-lang/crates.io-index`
error: specified package has no binaries
What does this mean? Do I have to build it from source first? What's the point of Cargo if it does not install it in the first place?
$ uname -a
Linux 4.6.1-2-ARCH #1 SMP PREEMPT Thu Jun 2 15:46:17 CEST 2016 x86_64 GNU/Linux
$ rustc --version
rustc 1.9.0
$ cargo --version
cargo 0.10.0 (10ddd7d 2016-04-08)
cargo install is used to install binary packages that happen to be distributed through crates.io.
If you want to use a crate as a dependency, add it to your Cargo.toml.
Read the Rust getting started guide and the Cargo getting started guide for further information. In short:
cargo new my_project
cd my_project
echo 'curl = "0.3.0"' >> Cargo.toml
Amusingly, you can install a third-party Cargo subcommand called cargo-edit using cargo install that makes it easier to modify your Cargo.toml file to add and remove dependencies!
cargo install cargo-edit
cargo add curl
cargo rm curl
An important thing to note is that every Cargo project manages and compiles a separate set of dependencies (some background info). Thus it doesn't make sense to install a compiled library. The source code for each version of a library will be cached locally, avoiding downloading it multiple times.
See also:
cargo install <library_name> --library (Cargo issue #2552)
cargo-add documentation (added to Cargo directly in 1.62.0)
I am setting up clingo-master in Ubuntu, which is an ASP app. But I when I followed this guide to cmake.
cmake -H./libgringo -B./gringoBin -DCMAKE_BUILD_TYPE=Release
I met the error:
CMake Error at CMakeLists.txt:70 (bison_target_or_gen):
unknown CMake command "bison_target_or_gen
I have installed bison, but the error was still there. I am new to linux, I have no idea what to do.
This is what the guide says:
When cloning the git repository, do not forget to update the submodules (with source releases, you can skip this step):
git submodule update --init --recursive
To build gringo, clingo, and reify in their default configurations in release mode, run:
cmake -H<SOURCE_DIR> -B<BUILD_DIR> -DCMAKE_BUILD_TYPE=Release
cmake --build <BUILD_DIR>
The resulting binaries and shared libraries will be in <BUILD_DIR>/bin and are ready to use.
To install all binaries and development files under cmake's install prefix (see the build options), run:
cmake --build <BUILD_DIR> --target install
To run the tests, enable option CLINGO_BUILD_TESTS (see build options) and run:
cmake --build <BUILD_DIR> --target test