Cython Panda Includes Broken on Windows

I’m not sure where the proper place to post this is, but I have an issue. On Windows, I can’t include the Panda3D include directory. I get this error:

It works fine on Mac. The project in question (a nice minimal sample for using Panda’s C++ API from cython) is here:

On the Mac, I get this output, the later part of which is the output produced by the compiled module:

This works great.

Cython works fine with C++ for me on Windows when I don’t include Panda’s include directory.

If I can get this resolved, I’ll publish my little example along with instructions and information.

Panda isn’t currently compilable by MinGW. It might be possible to make it work on that compiler (we were unable to years ago, due to a problem with DLL specification, but maybe things are better now). But it would be a lot of work, even if it is possible.

On Windows, you have to use MSVC to compile Panda.


I’m not trying to compile panda. I’m trying to compile a cython module that links against panda (I think thats the proper terminology). I can compile cython modules that make calls into python that was compiled with panda using MinGW just fine (in C or C++). But if I try to use any of panda’s harder files, I get that problem. Do you still think I should need MSVC?

Using distutils with cython and MinGW produced compiled modules that worked with Panda’s python just fine, no trouble at all (I didn’t have to mess with any settings at all). But, if I try to extern something from a panda header file, it spews the error.

Edit: I looked in cmath.I and it seems the issues are occurring on __asm blocks for csincos. Perhaps its failing to process inline asm functions, which I imagine I can’t simply skip, but I don’t need.

Parsing a header file is the same thing as compiling. If you can expose only code that doesn’t require exposing a Panda header file, you should be OK. This may mean placing the #include “panda.h” or whatever in a .cpp file only, and not in a .h file that will be parsed by MinGW.


Cython makes a .cpp file, and no .h files at all, so I have exactly 0 .h files already, and only one .cpp file with only one include from panda, #include “geom.h”

Here is the c++ file Cython generates:

MinGW seems to dislike the syntax for the __asm blocks. It expects a ( and not a { from what I can tell. I hacked cmath.I so it avoids them (they are already wrapped in an if statement), and commented out the include for minmax.h in dtoolbase.h which got it past those issues, but produced this error:

I suspect messing with the header files is probably not a good thing to do, but at least I made something different happen. It managed to make a .o and .def file that time.

Would be be good for me to try some simpler (trivial) C++ file? I don’t actually know C++, and I’ve never really done anything with header files, so I don’t know what to try. I tried a cpp file with nothing in it other than #include “geom.h” but it does the same thing (the error in my first post and the one above respectively) as the whole big Cython generated c++ file with both the the original and my modified header files.

I’m installing Microsoft Visual Studio 2008 C++ Express Edition. Maybe this will make it work. Thanks for the suggestions!

Well, I got a c++ Cython sample to compile with MSVC compiler, but I can’t make it work with Panda!

I get this:

I’m pretty clueless for how to progress from here. Any advice would be greatly appreciated.

Edit: I should mention that just as with MinGW, Cython works just fine as long as I don’t try to include any panda headers.

I think I’ve resolved all the compiler and Panda issues. I suspect my current issue (see last post) is a Cython bug, recorded here:

Thanks for the help!

I’ll keep an eye on it and if I get it to work, I’ll be back with a fix.