Can't compile msgpack Python extension under windows

1.2k views Asked by At

When I try to compile msgpack under windows with visual studio 2008 professional version by doing

Python setup.py build

I get

msgpack/_packer.cpp(316) : fatal error C1083: Cannot open include file: 'stdint.
h': No such file or directory

Apparently this is due to MS compiler not having proper C support, so I've downloaded the latest msinttypes which is supposed to fix this problem. If I place the inttypes.h and stdint.h under C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include and try to compile again, I get:

c:\work\tools\msgpack-python-0.4.0\msgpack-python-0.4.0\msgpack\sysdep.h(24) : e
rror C2371: 'int8_t' : redefinition; different basic types
        C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\stdint.h(87) : see
 declaration of 'int8_t'

Based on google searches, this looks like some other header file somewhere is defining int8_t. Actually, if I'm not mistaken the error says that it is stdint.h, which is the header file I've added from msinttypes to fix the problem in the first place. This machine also has vs.net 2010 professional installed, but I'm not sure if that could cause any problems.

Considering the fact that I have a full Python setup running under windows under this machine, I can't switch to mingw under Windows, because that'd probably cause issues since all the Python 2.7 code is compiled with visual c++ 2008.

How do I compile msgpack extension so that I use the fast version under windows?

2

There are 2 answers

1
Chris On

Compiling Python libraries on Windows can indeed be a pain.

I usually use precompiled binaries provided by Christoph Gohlke whenever possible. He appears to have a build of msgpack.

2
cubuspl42 On

Python relies on C ABI, I think that you can use it with MinGW without issues.

I don't know why both headers define int8_t but there is something more interesting. In Visual Studio 2008 _MSC_VER should equal 1500, so sysdep.h defines it as __int8. But stdint.h from msinttypes should also do this:

#if (_MSC_VER < 1300)
   typedef signed char       int8_t;
   ...
#else
   typedef signed __int8     int8_t;

Try to check what int8_t is typedefed to in both headers.