kivy / cymunk

Cython port of Pymunk
http://readthedocs.org/docs/cymunk/en/latest/
MIT License
45 stars 29 forks source link

problems building/importing on windows #26

Closed chozabu closed 9 years ago

chozabu commented 9 years ago

I get a crash upon entering "import cymunk" log below

Reading symbols from c:\kivy-1.8.0-py2.7-win32\python27\python.exe...(no debuggi ng symbols found)...done. (gdb) run Starting program: c:\kivy-1.8.0-py2.7-win32\python27\python.exe [New Thread 8180.0x1e84] Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information.

import cymunk

Program received signal SIGSEGV, Segmentation fault. 0x778a8dc9 in ntdll!TpCallbackMayRunLong () from C:\Windows\system32\ntdll.dll (gdb) bt

0 0x778a8dc9 in ntdll!TpCallbackMayRunLong ()

from C:\Windows\system32\ntdll.dll

1 0x74d57408 in iob ()

from C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161 _none_50934f2ebcb7eb57\msvcr90.dll

2 0x74d5740c in iob ()

from C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161 _none_50934f2ebcb7eb57\msvcr90.dll

tested with regular python 2.7 and kivy portable package gcc info: C:\Users\chozabu\cymunk\build\lib.win32-2.7>gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,obj c,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgo mp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-r untime-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.6.2 (GCC)

cython info Cython version 0.21b1 from pip or easy_install

while writing this, I also tried upgrading to: Cython version 0.20.2 from a pre-compiled binary, and rebuilding with no luck

chozabu commented 9 years ago

Just tested on my brothers win8 machine

C:\cymunk-master\cymunk-master\build\lib.win32-2.7>C:\MinGW\bin/gdb-python27 pyt hon GNU gdb (GDB) 7.5 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-mingw32". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from C:\Kivy-1.8.0-py2.7-win32\Python27\python.exe...(no debuggi ng symbols found)...done. (gdb) run Starting program: C:\Kivy-1.8.0-py2.7-win32\Python27\python.exe [New Thread 4136.0x11d4] Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information.

import cymunk

Program received signal SIGSEGV, Segmentation fault. 0x7727ec81 in ?? () (gdb) bt

0 0x7727ec81 in ?? ()

1 0x7727eb9f in ?? ()

2 0x7727ebcd in ?? ()

3 0x752e1eb5 in msvcrt!_libm_sse2_tan_precise ()

from C:\Windows\SysWOW64\msvcrt.dll

4 0x607d7408 in iob ()

from C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.8387 _none_5094ca96bcb6b2bb\msvcr90.dll

5 0x00000000 in ?? ()

(gdb)

chozabu commented 9 years ago

An attempt at using msvc 2008 express did not go so well, after running around a little getting some missing headers and making a few changes to chipmunk, it looks like vc2008 is no good for modern versions of chipmunk

Kovak commented 9 years ago

Chipmunk is based on c99 so I don't really see how any new features introduced in the compiler could really make it not work. Can you provide more details on the error? Also how did you get 2008 express running on Windows 8?

chozabu commented 9 years ago

I tried a few different combinations of windows versions and compilers on VMS and real hardware.

IIRC compiling chipmunk with mingw is problematic - after a while of fixing errors and attempting compile, I becaume suspicious this is not the right way to go

I don't quite recalls the issue with MSVS2008 - I think chipmunk has removed the compatible project files which did not help for starters... I may not have used 2008 express in win8, perhaps only win7

Sorry for the lack of information

Since my attempts, MS released this: http://www.microsoft.com/en-gb/download/details.aspx?id=44266 I'm tempted to give it a go, but am reluctant to spend too much time futzing around in windows at the moment...

chozabu commented 9 years ago

Extra information from my question on stackoverflow here: http://stackoverflow.com/questions/25403945/how-can-i-compile-cymunk-for-windows

chozabu commented 9 years ago

OK! Finally some progress!

The change that seemed to make it work was switching to -std=gnu99 from -std=c99 in setup.py

but for what it is worth, I also: added this to chipmunk.h `#ifndef WIN32

define WIN32

endif`

as it seemed necessary

and in chipmunk_types, replaced line 1, #include <stdint.h> with:

#ifdef _MSC_VER

typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;

#else
#include <stdint.h>
#endif

I used python(x,y) to install python, cython and mingw to compile

python setup.py build_ext --inplace -f --compiler=mingw32

I have a slightly old version of cymunk here ~1-~2 months

I'll tidy up the changes and try to get a more windows-compatible cymunk up as a PR as soon as practical.

Then with a little luck I can give kivent on windows a go https://github.com/Kovak/KivEnt/issues/15

spinningD20 commented 9 years ago

Awesome! I'll be giving that a try over the holiday weekend for sure to further validate your findings! This might convert me from cocos2d for python as my go-to...

chozabu commented 9 years ago

trugate: Submitted a PR that seems to make things work here: https://github.com/tito/cymunk/pull/28

note - if you are using python(x,y) check the list on install, make sure pygame, cython (and perhaps something else?) is ticked.

I'll probably merge this PR before the weekend, but regardless it'd be great to hear what setup/enviroment you have, and if this makes it work.

chozabu commented 9 years ago

trugate: this should now work. I have merged changes into master.

At one point (after things were working) I had a problem launching an app, with either kivy.bat's python, or python(x,y) - perhaps a combination of both - due to the (now redundant) call to the main cpInit function, should disable it soon.

I have not yet successfully built an exe from kivent, not yet tried on cymunk examples.

Will close this Issue if another person or two reports this working.

Also, re: Kovak: IIRC, I downloaded MSVC 2008 from some hard-to-find place on MS website, opened the installer, and clicked far too many times. Not sure why gnu99 instead of c99 fixed it, but its the flag people used on chipmunk forums for mingw. I'm interested enough to hear why if someone else knows, but not enough to look into it ;)

chozabu commented 9 years ago

Closing issue, fixed by https://github.com/tito/cymunk/pull/28

spinningD20 commented 9 years ago

Sorry for the delay. I have tried the latest, and it doesn't recognize the gnu99 std flag:

D:\Downloads\cymunk-latest\cymunk-master>python setup.py install running install running build running build_ext cythoning cymunk/python/cymunk.pyx to cymunk/python\cymunk.c warning: cymunk\python\shape.pxi:180:90: local variable 'info' referenced before assignment warning: cymunk\python\shape.pxi:181:58: local variable 'info' referenced before assignment warning: cymunk\python\shape.pxi:181:66: local variable 'info' referenced before assignment building 'cymunk' extension creating build creating build\temp.win32-2.7 creating build\temp.win32-2.7\Release creating build\temp.win32-2.7\Release\cymunk creating build\temp.win32-2.7\Release\cymunk\python creating build\temp.win32-2.7\Release\cymunk\Chipmunk-Physics creating build\temp.win32-2.7\Release\cymunk\Chipmunk-Physics\src creating build\temp.win32-2.7\Release\cymunk\Chipmunk-Physics\src\constraints C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Icymunk\Chipmunk-Physics\include -Icymunk\Chipmunk-Physic s\include\chipmunk -IC:\Python27\include -IC:\Python27\PC /Tccymunk/python\cymun k.c /Fobuild\temp.win32-2.7\Release\cymunk/python\cymunk.obj -std=gnu99 -ffast-m ath -fPIC -DCHIPMUNK_FFI cl : Command line warning D9002 : ignoring unknown option '-std=gnu99' cl : Command line warning D9002 : ignoring unknown option '-ffast-math' cl : Command line warning D9002 : ignoring unknown option '-fPIC' cymunk.c cymunk\Chipmunk-Physics\include\chipmunk/chipmunk.h(36) : fatal error C1083: Can not open include file: 'alloca.h': No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\c l.exe' failed with exit status 2

I am running Win 8.1 64bit, and installed the Microsoft VC Compiler package you mentioned above.

I'm thinking it's something to do with that, but I've always been unsure of how to fix that issue... I'm also assuming it can't find alloca.h because it didn't run with the proper flags?

Looking forward to seeing this working. Thanks for your efforts!

chozabu commented 9 years ago

@trugate I could have been more clear - you need to use MinGW.
If you are not familar with how to do this, http://stackoverflow.com/questions/3297254/how-to-use-mingws-gcc-compiler-when-installing-python-package-using-pip Looks to explain the process to some degree

I've tried it out with python+mingw from both kivy portable package and `python(x,y)`` (I think)

There may be a way to get it to compile with MSVC - but it sure wont be me who finds out how!

chozabu commented 9 years ago

I have updated the readme, here: https://github.com/tito/cymunk/commit/beeb37ac5c9dbf8740df501fb66a4ede274feefd
There is some offical information on building extensions here: https://docs.python.org/2/install/#location-and-names-of-config-files

@trugate what you probably really want to do (if you are aiming to use kivent), is use the Kivy Portable package, upgrade kivy, cython (detailed here http://kivy.org/docs/installation/installation-windows.html#use-development-kivy ) or otherwise set up those components ( detailed https://github.com/kivy/kivy/wiki/Using-Kivy-with-an-existing-Python-installation-on-Windows-%2864-or-32-bit%29 ) - After one of those, CyMunk should compile happily

spinningD20 commented 9 years ago

I did it! I think! :dancer: On Windows 8.1 64bit, I installed mingw's C++ Compiler, and set the path as shown in an answer from the SO link you posted. I did need to grab zlib1.dll from this package here (http://sourceforge.net/projects/libpng) and put it into c:\windows\SysWOW64 (if on 32bit windows then put it at c:\windows\system32, c:\windows\system32 on a 64 bit install is treated as a 64bit directory, irony somewhere there for folder names).

Now on to the other steps for kivent working in windows. Well, not now, but soon.

Thanks!

chozabu commented 9 years ago

@trugate Great to hear. Try the examples in cymunk before moving onto kivent, many of them depend on a subset of kivy/kivent.

what kind of python/mingw setup do you have?