Error build Rust for linux in macos - Openssl - rust

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

Related

can't install cargo wasm-pack

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.

How to set the C include path when compiling the proj-sys crate?

I am trying to use proj crate, but building proj-sys fails, not able to find C stdlib headers:
error: failed to run custom build command for proj-sys v0.12.2
/usr/local/include/proj.h:120:10: fatal error: 'stddef.h' file not found
After searching for a while, it seems that this issue is due to a different location of the include directory in different versions of gcc (or clang). I found how to provide the correct location to the C compiler, but how would I do it when building this crate with Cargo?
My gcc headers are in the /usr/lib/gcc/x86_64-linux-gnu/7.4.0/ folder, but I don't even know where they are looked for when the crate does its thing.
I have found the solution to my problem. It was just to install clang package.
On Debian-like systems, it's just:
sudo apt-get install clang

compilation error: No suitable bison/yacc found

I am using gcc8.2 and linux operating system. I have bison package installed. Still I am getting the below error:
echo "* Error: No suitable bison/yacc found. *"
echo " Please install the 'bison' package."
exit 1
I have checked the "$ac_cv_prog_YACC" and it is not having any value. It should be set to "bison -y" if bison is already installed.
Any idea why $ac_cv_prog_YACC does not have any value?
I got this error when compiling the conntrack-tools package (version 1.0.1)
You say
I have bison package installed.
But the test in the ./configure file disagrees. That means that it cannot find an executable file named bison anywhere in your $PATH. You should start by verifying that $PATH has the correct value and that there is an executable named bison. (Apparently the ./configure script for conntrack-tools only looks for bison and byacc, and not for yacc.)
I don't know much about yocto but I did find the following note in a change log for version 2.5.1:
bison-native no longer included in many dependency chains meaning some recipes need bison-native adding to DEPENDS

Trouble compiling Enlightenment foundation library 1.8.5

When I run configure.sh
I get this error:
checking for pkg-config... no
configure: error: pkg-config tool not found. Install it or set PKG_CONFIG environment variable to that path tool. Exiting...
I checked in aptitude and it says pkg-config is installed.
Need help with
"set PKG_CONFIG environment variable to that path tool."
runing on crunchbang 32bit
Try to set PKG_CONFIG=/usr/bin/pkg-config although it should be detected in such PATH automatically unless you've changed your PATH variable before.
You may also check if it is possible to pass path to pkg-config as a configure switch.
Check the output of ./configure --help | grep pkg.

trying to install hs-ffmpeg haskell package fails to find libdc1394

doing "cabal install hs-ffmpeg" fails like this:
checking for faacEncGetVersion in -lfaac... no
checking for zlibVersion in -lz... yes
checking for libdc1394... configure: error: Package requirements (libdc1394) were not met:
No package 'libdc1394' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables libdc1394_CFLAGS
and libdc1394_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
cabal: Error: some packages failed to install:
hs-ffmpeg-0.3.4 failed during the configure step. The exception was:
exit: ExitFailure 1
I have libdc1394-22 and libdc1394-22-dev installed on Ubuntu 9.10 Karmic Koala.
I'm thinking that the dependency needs to be updated to reflect the new package that supercedes libdc1394, but I'm not sure how to do that.
hs-ffmpeg's configure script is looking for a libdc1394.pc. For some reason, Ubuntu ships a libdc1394-2.pc instead.
Edit hs-ffmpeg's configure.ac to use the "correct" name and then run autoreconf, and it should work.
Something like mkdir -p ~/.pc; ln -s /usr/lib/pkgconfig/libdc1394-2.pc ~/.pc/libdc1394.pc; export PKG_CONFIG_PATH+=:~/.pc may work too.

Resources