Progress update

Following your cool recipe for ./configure, I ran into a problem during make: undefined reference to '_rpl_malloc'. I scratched my head and googled it. It turns out that this is due to a bug in autoconf. I followed the advice for the workaround described here and now I am able to fully compile mcrypt in Cygwin!

For this to work, I had to enter the following two commands just prior to running ./configure:

export ac_cv_func_malloc_0_nonnull=yes
export ac_cv_func_realloc_0_nonnull=yes

Although disabling 'realloc' is not described anywhere, I took a guess at it after make complained about it, and it seemed to work.

The second part is building the Python extension in distutils using the resulting DLL. The DLL for libmcrypt is created by Cygwin in C:\py\extend\libmcrypt-2.5.8\lib\.libs as "libmcrypt-4.dll", with a companion "export definitions" file suitably named "libmcrypt-4.dll.def". The DEF file is just a text file containing the names exported by the DLL. The next step is to create an import library "mcrypt.lib" that statically links to the DLL through the DEF file. In my case, I used a tool in VS 2003 called "lib.exe" in the "Vc7\bin" folder to generate "mcrypt.lib" by following these instructions. Once I had the .lib file, I ran:

setup.py build bdist_wininst

which builds the binary installer for python-mcrypt. After running this installer, one has to manually copy the DLL file to the Python path, otherwise DLL loading will fail in Python during import mcrypt. If there is a way for the DLL to be packaged and installed by the installer automatically, please, please let me know. Likewise, if there is a way to build the installer using MinGW alone, I'd like to hear it as well. (After all, this post is all about the free tools!)

I hope my notes here will help someone out there who may experience these problems so that they can work around them instead of throwing up their hands in frustration. Really, libmcrypt is a very fine library, and it's a shame that its maintainers decided to drop support for win32 builds.

Again, frank, thanks for this very useful tutorial!
Basil
Written in WikklyText.

Reply

The content of this field is kept private and will not be shown publicly.