can't install cargo wasm-pack - rust

When i run cargo install wasm-pack on windows 10 64-bit i get this error:
error: failed to run custom build command for `openssl-sys v0.9.65`
Caused by:
process didn't exit successfully: `C:\Users\vilgo\AppData\Local\Temp\cargo-install2J8ZNz\release\build\openssl-sys-932395a164949059\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
openssl-src: Enable the assembly language routines in building OpenSSL.
running "perl" "./Configure" "--prefix=C:\\Users\\vilgo\\AppData\\Local\\Temp\\cargo-install2J8ZNz\\release\\build\\openssl-sys-a51d272dcebf1fc5\\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" "VC-WIN64A"
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "Det går inte att hitta filen." }', C:\Users\vilgo\.cargo\registry\src\github.com-1ecc6299db9ec823\openssl-src-111.15.0+1.1.1k\src\lib.rs:469: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 `wasm-pack v0.10.0`, intermediate artifacts can be found at `C:\Users\vilgo\AppData\Local\Temp\cargo-install2J8ZNz`
Caused by:
build failed
How can i fix it?
I ran it in regular cmd.

The problem
I think your problem happened because all three of these things happened:
You probably started the wasm-pack build from an msys shell.
wasm-pack depends on Rust's OpenSSL bindings, which by default try to build OpenSSL by source.
OpenSSL's build scripts are written in Perl. The msys Perl doesn't create Windows paths with \ as a directory separator, which causes the OpenSSL build to fail.
The solutions
Any one of these three solutions should solve your problem:
Fix Step #3: Compile OpenSSL with the native Windows Perl
Make sure your default Perl installation is a "native" Windows Perl like Strawberry Perl. Make sure your build environment does not default to the msys perl. Then, retry compiling both wasm-pack and OpenSSL from source.
Fix Step #2: Use a precompiled OpenSSL library
You can build wasm-pack from source, but instruct the Rust OpenSSL bindings to look for a precompiled OpenSSL.
If you don't have it already, download and install vcpkg, which we'll use to install OpenSSL:
git clone https://github.com/Microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
Then use vcpkg to install OpenSSL:
vcpkg install openssl:x64-windows-static-md
(If this does not work, try vcpkg install openssl:x64-windows.)
And then try compiling wasm-pack. Set VCPKG_ROOT to tell the Rust OpenSSL build script where to look, and also set OPENSSL_NO_VENDOR=1 to discourage the build script from compiling OpenSSL from source.
set VCPKG_ROOT=c:\path\to\vcpkg\installation
set OPENSSL_NO_VENDOR=1
cargo install wasm-pack
Fix Step #1: Use a pre-compiled wasm-pack binary on Windows.
If you do not want to compile either wasm-pack or OpenSSL, you can use the Windows installer (wasm-pack-init.exe) on the rustwasm downloads page. Alternatively, you could also run your wasm-pack builds in Windows Subsystem for Linux (WSL).

Make sure you have the development packages of Open SSL installed.
For example, libssl-dev on Ubuntu or openssl-devel on Fedora. If OpenSSL is already installed and the crate still had trouble finding it, you can set the OPENSSL_DIR environment variable to specify the path for your Open SSL installation. If you are using windows you can use the Win32/Win64 OpenSSL Installation Project to provide a simple installation of OpenSSL on windows.

Related

Error build Rust for linux in macos - Openssl

Trying to compile for linux from a mac throws this error, I have openssl and pkg-config installed from brew.
And in the file ~/.cargo/config I have this configuration.
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
Error:
error: failed to run custom build command for `openssl-sys v0.9.72`
Caused by:
process didn't exit successfully: `/Users/Proyect/cvm/target/release/build/openssl-sys-66182f9fe15cdddc/build-script-main` (exit status: 101)
run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit status: 1\nerror: could not find system library 'openssl' required by the 'openssl-sys' crate\n\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'openssl' found\n"
--- stderr
thread 'main' panicked at '
Could not find directory of OpenSSL installation, and this `-sys` crate cannot
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it, you can set the `OPENSSL_DIR` environment variable for the
compilation process.
Make sure you also have the development packages of openssl installed.
For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
If you're in a situation where you think the directory *should* be found
automatically, please open a bug at https://github.com/sfackler/rust-openssl
and include information about your system as well as this message.
$HOST = x86_64-apple-darwin
$TARGET = x86_64-unknown-linux-gnu
openssl-sys = 0.9.72
', /Users/user/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.72/build/find_normal.rs:180: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
The error message contains three possible solutions:
First make sure it is really installed including for development (which is what you need if you want to compile code against openssl):
Make sure you also have the development packages of openssl installed.
For example, libssl-dev on Ubuntu or openssl-devel on Fedora.
If it is already really installed, then it could not be found. This can be fixed by adding the directory containing `openssl.pc' to the PKG_CONFIG_PATH environment variable:
Package openssl was not found in the pkg-config search path. Perhaps
you should add the directory containing `openssl.pc' to the
PKG_CONFIG_PATH environment variable.
Or by setting the OPENSSL_DIR to point to where the openssl code is on your system:
Could not find directory of OpenSSL installation, and this -sys
crate cannot proceed without this knowledge. If OpenSSL is installed
and this crate had trouble finding it, you can set the OPENSSL_DIR
environment variable for the compilation process.
After a lot of trying and trying I found this script that compiles for linux from mac.
You just have to copy it to the root folder of the project and run it.
try add
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
to your Cargo.toml

Error while compiling suricata on amazon linux

I am trying to install suricata in Amazon Linux ec2 instance
I got the following error while compiling
error: process didn't exit successfully: rustc -vV (exit code: 1)
--- stdout
rustc 1.35.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.35.0
--- stderr
error: couldn't load codegen backend "/usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so": "/usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so: symbol _ZNK4llvm10ModulePass17createPrinterPassERNS_11raw_ostreamERKSs, version LLVM_7 not defined in file libLLVM-7.so with link time reference"
Does anyone have an idea how it can be solved?
Is there a specific rust type for Amazon Linux?
I tried to install rust manually, but it says that it already exists.
I tried to uninstall and install it again several times
I was also having the same issue with Suricata. I am also using Amazon Linux and after some digging, the error is related to the clang library. I had to yum install this package and reconfigure and make
yum install llvm7.0
//reconfigure and recompile surticata
./configure --enable-rust
make

How to cross-compile Rust code for the Raspberry Pi Zero W

I am attempting to cross-compile Rust code on my 64-bit x86 laptop to run on the Raspberry Pi Zero W. I installed the arm-unknown-linux-gnueabihf toolchain using Rustup, but when I run cargo build --target arm-unknown-linux-gnueabihf, I get this error:
Internal error occurred: Failed to find tool. Is arm-linux-gnueabihf-gcc installed?
I tried to install the arm-linux-gnueabihf-gcc package from AUR, but that kept failing because of some sort of GPG key error, so I just decided to make my own cross-compiler using crosstool-ng.
I tried to point Cargo at my newly built cross-compiler using a ~/.cargo/config file:
[target.arm-unknown-linux-gnueabihf]
linker = "/home/ibi/x-tools/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gcc"
But Cargo seems to be ignoring this and giving me the same error. How do I fix this?
It worked when I set an environment variable:
$ export CC="/home/ibi/x-tools/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gcc"

Invalid configuration i686-redhat-linux-gnu on CentOS

I launch this command to build rpm package:
#>rpmbuild --rebuild -vv vqadmin-toaster-2.3.7-1.4.1.src.rpm
I'm on CentOs 6.4 and i want to build and install qmailtoaster packets.
Only this packet get an error:
checking build system type... Invalid configuration 'i686-redhat-linux-gnu': machine 'i686-redhat-linux' not recognized
What can i do? this is first time that i'm compiling RPM packages, any ideas?
i also run into the same problem, according to qmailtoaster installation script the command suppose to be
rpmbuild --rebuild --with cnt5064 vqadmin-toaster-2.3.7-1.4.1.src.rpm
built it has the same error msg as above
and I Google around and found out
vqadmin build error
many of our programs are running automake versions that PREDATE 64-bit linux... and while most apps will build just fine (albeit less optimized), vqadmin 2.3.7 does NOT build successfully in this "unknown-linux" environment.
He offers a x86_64 rpm at the bottom

Openssl header not found -- error

I need to compile a libwebsocket library for my ARM target which requires openssl for its functioning.
I am getting following error when i build latest libwebsocket at the time of, cmake ...
But openssl is installed here
whereis openssl
openssl: /usr/bin/openssl /usr/bin/X11/openssl /usr/share/man/man1/openssl.1ssl.gz
=================================== Error ================
-- Looking for 4 include files stdlib.h, ..., float.h - found
-- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found version "1.2.7")
ZLib include dirs: /usr/include
ZLib libraries: /usr/lib/arm-linux-gnueabihf/libz.so
Compiling with SSL support
CMake Error at /usr/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES
OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:291 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-2.8/Modules/FindOpenSSL.cmake:313 (find_package_handle_standard_args)
CMakeLists.txt:436 (find_package)
-- Configuring incomplete, errors occurred!
======================================= openssl is here ========================
ignite#ignite:~/sbox2/rootfs/rfs-raspbian_2/home/pi/libwebsockets/build$ whereis openssl
openssl: /usr/bin/openssl /usr/bin/X11/openssl /usr/share/man/man1/openssl.1ssl.gz
actually i have, source tarball from here. it have configure script to make & make install
http://www.openssl.org/source/
openssl-1.0.1e.tar.gz
So with this (openssl-1.0.1e.tar.gz) will be the right package to get --> openssl-dev or openssl-devel --- so that i can resolve this error ?
So with this (openssl-1.0.1e.tar.gz) will be the right package to get --> openssl-dev or openssl-devel --- so that i can resolve this error ?
The openssl-dev packages are for development on the host machine (which is probably x86 or x64 family). You need a cross compiled library for the target (and not the host). So openssl-dev will probably not solve your problem.
Are you targeting a generic ARM processor, iOS, or Android? If the former, you will need an arm cross-toolchain with paths set appropriately. I'm not aware of a good tutorial on cross compiling the library (and I've suffered it in the past).
There are some prebuilt configurations for generic cross compiling. Open Configure and config, and look at some of the triples. (OpenSSL does not use Automake and friends).
If iOS or Android, the OpenSSL wiki has some examples of cross compiling for the platforms. See, for example, FIPS Library and Android. The setenv-android.sh script is most important because it set paths, sysroot and toolchains. Once paths and toolschains are set, the rest is easy.
If you are targeting a generic ARM, then you could use the Android setenv-android.sh as a starting point for your generic build. Once you complete the build, then point OPENSSL_ROOT_DIR into the install directory for ARM.

Resources