Migrated from: https://gitlab.com/m2crypto/m2crypto/-/issues/271
Created by: mobilE K. G (@mobilekg)
Created at: 2020-01-15T18:34:07.867Z
Try to build in Windows 10 with Python 3.7 and Visual Studio build tool 2019
python setup.py build --openssl=D:\dev\OpenSSL-Win64\v1.1.1d
Get the following error:
...
SWIG/_m2crypto_wrap.c(9511): error C2037: left of 'num' specifies undefined struct/union 'stack_st'
SWIG/_m2crypto_wrap.c(9531): error C2037: left of 'num' specifies undefined struct/union 'stack_st'
SWIG/_m2crypto_wrap.c(9560): error C2037: left of 'data' specifies undefined struct/union 'stack_st'
...
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
Any hint, please.
On 2020-01-17T17:34:17.953Z, mobilE K. G wrote:
Find info from appveyor.yml
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017So I guess Visual Studio 2019 is not supported yet?
On 2020-01-23T15:40:26.448Z, Matěj Cepl wrote:
What version of swig you have installed? Could you attach complete build log, please?
On 2020-02-02T10:06:28.951Z, mobilE K. G wrote:
Follow this instruction and everything is fine now https://github.com/iOSForensics/pymobiledevice/issues/25#issuecomment-576119104
BTW, here are the distributions I build. Hopefully, it can help someones. https://github.com/MobilEKG/M2Crypto/releases
The commented linked:
Some builds for m2crypto for specific versions of Python are available from their CI: https://ci.appveyor.com/project/m2crypto/m2crypto/history. Try selecting a version, selecting a job that matches your Python version, then going to the "Artifacts" tab and downloading an installer. To install a .whl file, see step 11 of my build tutorial below.
I have also attached the m2crypto module that I have built on Windows 10 x64, Python 3.8.1. It should work on any x64-based version of Windows with any version of Python 3.8.X. M2Crypto-0.35.2.win-amd64-py3.8.zip
However, if you are unable to find a build that matches your Python version and system type and architecture, you may need to manually build m2crypto. I adapted the build steps from their CI build scripts: https://gitlab.com/m2crypto/m2crypto/blob/master/appveyor.yml. I built the module by doing the following:
Install the latest Build Tools for Visual Studio 2019. See https://visualstudio.microsoft.com/downloads/ under "All Downloads" -> "Tools for Visual Studio 2019". This direct link was active as of this writing: https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16 In the installer, select "C++ Build Tools", install, and reboot if necessary. Install the latest full (not Light) OpenSSL for your architecture (Win64/Win32). Current version as of this writing is 1.1.1d. Make note of the directory to which you install OpenSSL. https://slproweb.com/products/Win32OpenSSL.html In PowerShell, install the Chocolatey package manager. I used this command from their website: Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) Install swig with Chocolatey (in PowerShell). choco install -r -y swig Install the pywin32 dependency. Run pip install pywin32. If you have problems, try first running pip install wheel. To get pip to target a specific Python installation, try launching it using py -[version] -m pip install [module]. Note: you may need to use an elevated (administrator) PowerShell to install Python modules. Get the latest m2crypto code. If you have git installed, run git clone https://gitlab.com/m2crypto/m2crypto. Otherwise, download and extract the code from GitLab: https://gitlab.com/m2crypto/m2crypto/-/archive/master/m2crypto-master.zip Use cd to change into the directory m2crypto was cloned/extracted to. Assuming python launches your desired Python interpreter version, run python setup.py build --openssl="C:\Program Files\OpenSSL-Win64" --bundledlls, replacing C:\Program Files\OpenSSL-Win64 with the directory to which you installed OpenSSL. (On some systems you can use the py launcher to specify a Python version to use, run py -h for more information.) Generate the installable files. python.exe setup.py bdist_wheel bdist_wininst bdist_msi. Install the module. cd into the dist directory and run pip install M2Crypto-0.35.2-cp38-cp38-win_amd64.whl, replacing the filename with the generated .whl file. If you have problems, try first running pip install wheel. To get pip to target a specific Python installation, try launching it using py -[version] -m pip install [module]. Alternatively, you can run the generated .exe or .msi installer. Note: you may need to use an elevated (administrator) PowerShell to install Python modules.
Asked in https://gitlab.com/m2crypto/m2crypto/-/issues/271#note_1932105701 for merge review with the updated instructions.
Matěj Cepl referenced this ticket in commit 039046f.
Matěj Cepl referenced this ticket in commit ba9b6ba.