Error building openssl-sys crate on Windows - windows

I am trying to compile a Rust program on Windows, but I get this error message:
Compiling openssl-sys v0.6.4
failed to run custom build command for `openssl-sys v0.6.4`
[...]
failed to execute command: The system couldn't find the specified file. (os error 2)
Is `gcc` not installed? (see https://github.com/alexcrichton/gcc-rs#windows-notes for help)
--- stderr
thread '<main>' panicked at 'explicit panic', C:\Users\User\.cargo\registry\src\github.com-0a35038f75765ae4\gcc-0.3.12\src\lib.rs:510
Cargo compiled every other package without problem, but it can't compile the openssl package.
I searched for help with this specific error and found a github issue for hyperium. The first answer references the openssl building guide for Windows.
I don't understand exactly how I have to build openssl in Windows. I installed MinGW and added the bin path to the global PATH variable, so gcc is reachable, but this did not solve the error.
I use Rust 1.2 and Cargo 0.4.0. My project is an example for a Telegram API wrapper.

1) Download ssl
Installs Win32 OpenSSL v1.0.2d
Install it here: C:\OpenSSL-Win32,C:\OpenSSL-Win32\include,C:\OpenSSL-Win32\lib
2) Install MinGW,and add system env path ,,C:\MinGW\bin,important,MinGW's installed path contain char 'MinGW '
3) cmd run env OPENSSLLIBDIR=C:/OpenSSL-Win32/lib OPENSSLINCLUDEDIR=C:/OpenSSL-Win32/include cargo build

Related

./configure doesn't find Qt5Core, QT5GUI, QT5Widgets

I've recently replaced Win10 by Linux Debian 11.2 on my PC (hence I'm a newbee in Linux). Now, not all programs are available as deb-Files.
I tried to compile source code - here a synthesizer ams-2.2.0 - from a tar.gz files (after unzipping into a separate folder) with steps (as written in the INSTALL.TXT to this source, and obviously usual)
./configure
make
make install
I get a bunch of error messages for missing files, when running ./congigure most resolved by installation of missing packages, but at last it fails with error message:
checking for QTCore Qt5Gui Qt5Widgets >= 5.0... no
configure: error: cannot find Qt5 library >= 5.0
(hope to get all written correctly, because I can't copy from the terminal ... Ctrl-Shift-C doesn't seem to work)
I checked the installation in synaptics and found that Qt-Version is 5.12. So what's wrong here?
I'm afraid to have this error message everytime I try to compile different source codes.
You need to install libqtcore and libqtwidgets with development headers, they are in qtbase5-dev package.
sudo apt install build-essential qtbase5-dev qtchooser

Getting error while running mediapipe on macOS; Building C++ command-line example apps

I am trying to use mediapipe for a university project and have installed it, even successfully ran the Hello World! in C++ example app but when I am trying to build the C++ command-line example, it is giving me errors.
I ran this:
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu
and the result I got is this:
DEBUG: /private/var/tmp/_bazel_kanzashaikh/c191ae13e9137350b50f6a19ce94bf21/external/rules_foreign_cc/workspace_definitions.bzl:15:10: WARNING: This branch is deprecated and no longer recieving updates. Please update to main or choose a specific commit to pin in your workspace.
INFO: Build option --compilation_mode has changed, discarding analysis cache.
ERROR: Error fetching repository: java.io.IOException: The repository's path is "/usr/local/opt/opencv#3" (absolute: "/usr/local/opt/opencv#3") but this directory does not exist.
ERROR: /Users/kanzashaikh/development/mediapipe/third_party/BUILD:178:6: //third_party:opencv_binary depends on #macos_opencv//:opencv in repository #macos_opencv which failed to fetch. no such package '#macos_opencv//': The repository's path is "/usr/local/opt/opencv#3" (absolute: "/usr/local/opt/opencv#3") but this directory does not exist.
ERROR: Analysis of target '//mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.194s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 237 targets co
nfigured)
How do I solve it?
before building desktop examples, you should setup opencv. also for android examples you should setup android sdk and ndk.
there is a builtin script for setting up opencv and you can execute it.
for setting up opencv:
bash setup_opencv.sh
and for android sdk and ndk:
bash setup_android_sdk_and_ndk.sh
I am assuming you are running a M1 machine, as Homebrew is now installing Intel binaries under /usr/local and ARM ones under /opt/homebrew.
In your case, when building, bazel is looking for opencv#3 package at /usr/local/opt/opencv#3 and immediately throws an error as the package is located at /opt/homebrew/opt/opencv#3.
Thus, you have two choices:
Open WORKSPACE file from your bazel project and modify the path for each package accordingly
Make a symbolic link to /opt/homebrew/opt in /usr/local by running: sudo ln -s /opt/homebrew/opt opt

Can't install cargo-binutils library: Failed to find tool. Is `gcc.exe` installed?

When I run cargo install cargo-binutils, I get the below error. I have gcc installed and in my path, to the point where where gcc correctly returns the location.
gcc version: gcc.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
I couldn't find a solution to work, including the explanation in the link listed in the error. I'm on Windows 10.
error: failed to run custom build command for \`backtrace-sys v0.1.37`
Caused by:
process didn't exit successfully: \`C:\Users\blahblah\AppData\Local\Temp\cargo-installEvEWRS\release\build\backtrace-sys-075604757ab74d2a\build-script-build` (exit code: 1)
--- stdout
cargo:rustc-cfg=rbt
TARGET = Some("x86_64-pc-windows-gnu")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-pc-windows-gnu")
CC_x86_64-pc-windows-gnu = None
CC_x86_64_pc_windows_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-pc-windows-gnu = None
CFLAGS_x86_64_pc_windows_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running: "gcc.exe" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "src/libbacktrace" "-I" "C:\\Users\\BRENDA~1.BUR\\AppData\\Local\\Temp\\cargo-installEvEWRS\\release\\build\\backtra
ce-sys-1e77a4d4c3ba2eda\\out" "-fvisibility=hidden" "-DBACKTRACE_SUPPORTED=1" "-DBACKTRACE_USES_MALLOC=1" "-DBACKTRACE_SUPPORTS_THREADS=0" "-DBACKTRACE_SUPPORTS_DATA=0" "-DHAVE_DL_ITERATE_PHDR=
1" "-D_GNU_SOURCE=1" "-D_LARGE_FILES=1" "-Dbacktrace_full=__rbt_backtrace_full" "-Dbacktrace_dwarf_add=__rbt_backtrace_dwarf_add" "-Dbacktrace_initialize=__rbt_backtrace_initialize" "-Dbacktrac
e_pcinfo=__rbt_backtrace_pcinfo" "-Dbacktrace_syminfo=__rbt_backtrace_syminfo" "-Dbacktrace_get_view=__rbt_backtrace_get_view" "-Dbacktrace_release_view=__rbt_backtrace_release_view" "-Dbacktra
ce_alloc=__rbt_backtrace_alloc" "-Dbacktrace_free=__rbt_backtrace_free" "-Dbacktrace_vector_finish=__rbt_backtrace_vector_finish" "-Dbacktrace_vector_grow=__rbt_backtrace_vector_grow" "-Dbacktr
ace_vector_release=__rbt_backtrace_vector_release" "-Dbacktrace_close=__rbt_backtrace_close" "-Dbacktrace_open=__rbt_backtrace_open" "-Dbacktrace_print=__rbt_backtrace_print" "-Dbacktrace_simpl
e=__rbt_backtrace_simple" "-Dbacktrace_qsort=__rbt_backtrace_qsort" "-Dbacktrace_create_state=__rbt_backtrace_create_state" "-Dbacktrace_uncompress_zdebug=__rbt_backtrace_uncompress_zdebug" "-D
macho_get_view=__rbt_macho_get_view" "-Dmacho_symbol_type_relevant=__rbt_macho_symbol_type_relevant" "-Dmacho_get_commands=__rbt_macho_get_commands" "-Dmacho_try_dsym=__rbt_macho_try_dsym" "-Dm
acho_try_dwarf=__rbt_macho_try_dwarf" "-Dmacho_get_addr_range=__rbt_macho_get_addr_range" "-Dmacho_get_uuid=__rbt_macho_get_uuid" "-Dmacho_add=__rbt_macho_add" "-Dmacho_add_symtab=__rbt_macho_a
dd_symtab" "-Dmacho_file_to_host_u64=__rbt_macho_file_to_host_u64" "-Dmacho_file_to_host_u32=__rbt_macho_file_to_host_u32" "-Dmacho_file_to_host_u16=__rbt_macho_file_to_host_u16" "-o" "C:\\User
s\\BRENDA~1.BUR\\AppData\\Local\\Temp\\cargo-installEvEWRS\\release\\build\\backtrace-sys-1e77a4d4c3ba2eda\\out\\src/libbacktrace/alloc.o" "-c" "src/libbacktrace/alloc.c"
--- stderr
error occurred: Failed to find tool. Is `gcc.exe` installed? (see https://github.com/alexcrichton/cc-rs#compile-time-requirements for help)
https://github.com/alexcrichton/cc-rs#compile-time-requirements says:
Windows platforms targeting MinGW (e.g. your target triple ends in -gnu)
require cc to be available in PATH. We recommend the
MinGW-w64 distribution, which is using the
Win-builds installation system.
You may also acquire it via
MSYS2, as explained [here][msys2-help]. Make sure
to install the appropriate architecture corresponding to your installation of
rustc. GCC from older MinGW project is compatible
only with 32-bit rust compiler.
Try creating a symlink or hardlink to GCC called cc, somewhere on your path.
This happened to me as well. In my case I got:
failed to run custom build command for zstd-sys v2.0.1+zstd.1.5.2
Caused by: process didn't exit successfully:
C:\Users\asili\Documents\Programming\zero2prod\target\debug\build\zstd-sys-f37cc8bfd3eec6ac\build-script-build
(exit code: 1)
error occurred: Failed to find tool. Is gcc.exe installed? (see
https://github.com/alexcrichton/cc-rs#compile-time-requirements for
help)
I was able to solve it by following the steps on installing the Visual C++ extension from the VS Code marketplace.
This is how I did it:
Go to MSYS2.org https://www.msys2.org/ (You will also see the installation steps on the site, in case this answer gets outdated).
Download and install msys2-x86_64-20220603.exe (or whichever version is current). The installation is pretty straightforward, just take a note on the installation path as you will need to add this to the environment PATH later on.
A new program called "MSYS2" should've been installed. Open it, and you'll see a terminal window in it. You will run ALL of the commands mentioned below in this terminal. If you close it, open it again.
Run:
pacman -Syu
This will update the packages and databases.
Run (Again - This step may not be needed, but is recommended by MSYS2 in case packages need an additional updates.)
pacman -Syu
Run:
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
You will now see a selection of all the packages. If you don't know which to choose, just press enter on your keyboard and you shall get all of them (that's what I ended up doing).
After that, gcc.exe will be installed the bin folder of mingw64. Therefore:
Add theC:\msys64\mingw64\bin file path to your path environment variable (or Wherever you decided to install it).
In case you need assistance on adding to the path, check out this link.
Remember to restart your CMD/Windows Terminal/Power Shell for the environment path to take place.

How to fix "CMake Error: Could not find CMAKE_ROOT"?

Executing Command:
MSVS201364bit.cmd && python make_aptx_dec.py --x86-64.win.clhd.bin
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
Installed latest version 3.6.2 cmake still facing this issue.
Are you sure that you are executing cmake by its final full path name and not symbolic link? Currently cmake won't work properly if you execute it through a symbolic link

easy_install M2Crypto failing on Windows platform

I am attempting to install M2Crypto on a Windows XP platform. I have Python, easy_install and SWIG installed, but when I attempt to easy_install M2Crypto I get the following:
SWIG\_m2crypto.i(31) : Error: Unable to find 'openssl\opensslv.h'
SWIG\_m2crypto.i(45) : Error: Unable to find 'openssl\safestack.h'
SWIG\_evp.i(12) : Error: Unable to find 'openssl\opensslconf.h'
SWIG\_ec.i(7) : Error: Unable to find 'openssl\opensslconf.h'
error: Setup script exited with error: command 'swig.exe' failed with exit status 1
I have read elsewhere that people have suggested easy_install openssl-devel, but that simply tells me that there are no packages found with that name. Is the name perhaps case-sensitive (I've tried various permutations without success), or does that advice not apply to Windows?
I'm not looking for alternatives to M2Crypto. I am picking up some existing code that uses it, so I need to get my development environment to be able to run what's already written.
As jay stated in his answer you should try to build it from source. And I tried. The setup.py does not recognize the --openssl option. Looking at the output from the default setup.py I realized that the search location was c:\pkg and not c:\pkg\openssl.
The solution:
Download and install OpenSSL from Win32 OpenSSL
Copy the lib and include folders to c:\pkg
Check that swig.exe is available in your path
Run easy_install M2Crypto
Worked for me like a charm.
Had a similar problem. After downloading the source package of M2Crypto and reading the INSTALL file I found the following:
Differences when installing on Windows
--------------------------------------
Before building from source, you need to install OpenSSL's include files,
import libraries and DLLs. By default setup.py assumes that OpenSSL include
files are in ``c:\pkg\openssl\include``, and the import libraries
in ``c:\pkg\openssl\lib``. As with other platforms, you can specify a different
OpenSSL location with --openssl option to build_ext command.

Resources