cpython-3.xpyhook

Issues building pywinhook from source


Python interpreter: 3.7

Python library: pywinhook https://pypi.org/project/pyWinhook/.

Objective: Add some features or functions to pywinhook library.

Tutorial to build this library: This library was done from pyHook library. That is why I am using the following tutorial to build this library https://sourceforge.net/p/pyhook/wiki/PyHook_Build_Instructions/.

Steps done: I downloaded the source code of the library. I installed the MinGW and SWIG. I added the environment variables required.

Issues: When I am executing python setup.py build -cmingw32, I got the following error and I could not continue with the process. If someone could explain to me what I should do. Thanks in advance

The last lines of the execution was:

build\temp.win-amd64-3.7\Release\pywinhook\cpyhook_wrap.o:cpyHook_wrap.c:(.text+0x1bb6): undefined reference to `_imp__PyEval_RestoreThread'
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1

Solution

  • After a long search and based on the link shared by @Juan Botero, I realized that I am compiling in 64-bit. The solution was as follows:

    1. Download MinGW-w64 on https://sourceforge.net/projects/mingw-w64/

    2. Add the following statement in the file cygwinccompiler.py, due to I am using an updated version of VB.

      elif msc_ver == '1900': return ['msvcr100']

    3. I run the instruction written in the tutorial and it works.