Take the 2-minute tour ×

M2Crypto uses the standard

python setup.py [build|install]

step to build and install the module. distutils/setuptools allows for some tweaking, but I can't seem to find a way to statically link OpenSSL into the module - there doesn't appear to be any facility to make this change.

Is there any way to build M2Crypto with a statically linked OpenSSL? (I am willing to bail on setup.py and do it by hand if that's the only way, would just like to query if anyone has tackled this before I go and spend hours solving an already solved problem).

share|improve this question
What platform(s) are you using? And can you say why you want to static link when many platforms strongly discourage it? –  Ned Deily Jan 19 '11 at 22:35
Platforms are linux and win32. Our export waiver from the commerce department requires that openssl not be replaceable by the end user by swapping out the library, so we can't use shared linkage. –  Nick Bastin Jan 19 '11 at 23:26
add comment

1 Answer

up vote 1 down vote accepted

You need the static link libraries for OpenSSL (ssleay32, libeay32), which you might have to build yourself. On Windows you'll have to change setup.py to include some more libraries, e.g.:

-self.libraries = ['ssleay32', 'libeay32']
+self.libraries = ['ssleay32', 'libeay32', 'crypt32', 'user32', 'gdi32', 'kernel32', 'ws2_32', 'advapi32']

Works for me.

share|improve this answer
Interesting, I'll try this. I have the static libraries, but possibly hiding the shared ones will help. –  Nick Bastin Jan 19 '11 at 23:25
I've edited your answer to reflect actually don't need zlib, but you do need crypt32. Otherwise it was correct from the start. –  Nick Bastin Jan 26 '11 at 22:54
add comment

Your Answer


