I was trying to add a little physics to my kivy game but having a hard time getting "Kivent" and cymunk to run. I think everything has build correctly but the examples only start with python 2 but not with python3.
I got the following error message:
mic@lin:~/python/kivy-kivent-12766f1/examples/4_adding_physics_objects> python3 main.py
[INFO ] [Logger ] Record log in /home/mic/.kiv/logs/kivy_16-01-26_48.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v3.4.1 (default, May 23 2014, 17:48:28) [GCC]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored)
[INFO ] [Window ] Provider: pygame(['window_egl_rpi'] ignored)
[INFO ] [GL ] OpenGL version <b'3.0 Mesa 10.3.7'>
[INFO ] [GL ] OpenGL vendor <b'Intel Open Source Technology Center'>
[INFO ] [GL ] OpenGL renderer <b'Mesa DRI Intel(R) Haswell Mobile '>
[INFO ] [GL ] OpenGL parsed version: 3, 0
[INFO ] [GL ] Shading version <b'1.30'>
[INFO ] [GL ] Texture max size <8192>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [OSC ] using <multiprocessing> for socket
Traceback (most recent call last):
File "main.py", line 8, in <module>
import kivent_cymunk
File "/home/mic/python/kivy-kivent-12766f1/examples/4_adding_physics_objects/kivent_cymunk/__init__.py", line 1, in <module>
from . import physics
ImportError: dynamic module does not define init function (PyInit_physics)
I have searched the whole day but did not found any answer. Kivent core alone works so it must be an issue with cymunk or kivent_cymunk. I had some issues to build these modules using python3 so if you have a good advice to install these builds it would also be welcome.
The error for the setup of kivent_cymunk using python3 was:
building 'kivent_cymunk.physics' extension
gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -I/usr/include/python3.4m -c kivent_cymunk/physics.c -o build/temp.linux-x86_64-3.4/kivent_cymunk/physics.o -std=c99 -ffast-math
In file included from kivent_cymunk/chipmunk/chipmunk.h:116:0,
from kivent_cymunk/physics.c:253:
kivent_cymunk/chipmunk/constraints/cpConstraint.h: In function ‘cpConstraintActivateBodies’:
kivent_cymunk/chipmunk/constraints/cpConstraint.h:94:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
cpBody *b = constraint->b; if(b) cpBodyActivate(b);
^
cc1: some warnings being treated as errors
error: command 'gcc' failed with exit status 1
My System is: OpenSuse 13.2.
I hope I was able to explain the problem and anyone can help.
Thanks in advance!
So after multiple hours of compiling and copying I finally found my answer.
It was amazingly easy after I found out, that cymunk hasn't compiled correctly. The problem was, that the compiler with python3 has set the
-Werror=declaration-after-statement
With python 2 this was not set. To compile cymunk and kivent_cymunk correctly using python 3 I had to add the
-Wno-error=declaration-after-statement
to the "extra_compile_args" in setup.py. After that everything worked nicely (except a lot of warnings).
Does anyone know why these declarations are that bad? Or why the gcc compiler has different arguments for python 2 and 3?
I hope I save someone a lot of work with that answer.
Best, M