I am trying to compile the Python bindings for OpenSSL (pyOpenSSL) on Windows Vista x64 using Visual Studio 2008. When I run python setup.py build_ext -I C:\OpenSSL\include, it dies with the following error:
building 'OpenSSL.crypto' extension C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I\OpenSSL\include -IC:\Python26\include -IC:\Python26\PC /Tcsrc/crypto/x509name.c /Fobuild\temp.win-amd64-2.6\Release\src/crypto/x509name.obj x509name.c src/crypto/x509name.c(16) : error C2133: 'crypto_X509Name_methods' : unknown size error: command ''C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe'' failed with exit status 2
When I look at the source in question, I see the following at line 16:
static PyMethodDef crypto_X509Name_methods[];
My C is very rusty, so I don’t remember if you can do this or not. Since this is a Python library, I would guess that is is written to compile in gcc, but I don’t have a Cygwin environment installed on this computer. Is there some switch that I can use to get this code to compile with VS2008?
Answer:
Later on in the code, there is this:
/* * ADD_METHOD(name) expands to a correct PyMethodDef declaration * { 'name', (PyCFunction)crypto_X509_name, METH_VARARGS } * for convenience */ #define ADD_METHOD(name) \ { #name, (PyCFunction)crypto_X509Name_##name, METH_VARARGS, crypto_X509Name_##name##_doc } static PyMethodDef crypto_X509Name_methods[] = { ADD_METHOD(hash), ADD_METHOD(der), ADD_METHOD(get_components), { NULL, NULL } }; #undef ADD_METHOD
Going off of the suggestion of Neil Butterworth, I changed the line in error from:
static PyMethodDef crypto_X509Name_methods[];
to:
static PyMethodDef crypto_X509Name_methods[4];
and the code compiled.
Thanks to everyone.
You probably have a situation like this:
which compiles as C with gcc. I’m not sure it should (it is not valid C++) but I’m not enough of a C language lawyer to tell you for sure.