c - How can I fix a crash on the Chipmunk 2D physics engine demos? (freezes on collision) - Stack Overflow

admin2025-04-22  0

I'm trying to start out using the Chipmunk physics engine and I just installed the latest version. I opened the installed folder and inputted the commands cmake ., then make as the website said. When compiling all the files, a few warnings showed up:

[  4%] Building C object src/CMakeFiles/chipmunk.dir/cpBBTree.c.o
In file included from /home/usuario/cpp_libraries/Chipmunk-7.0.3/include/chipmunk/chipmunk_private.h:25,
                 from /home/usuario/cpp_libraries/Chipmunk-7.0.3/src/cpBBTree.c:25:
/home/usuario/cpp_libraries/Chipmunk-7.0.3/src/cpBBTree.c: In function ‘partitionNodes’:
/home/usuario/cpp_libraries/Chipmunk-7.0.3/include/chipmunk/chipmunk.h:72:26: warning: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
   72 |         #define cpcalloc calloc
/home/usuario/cpp_libraries/Chipmunk-7.0.3/src/cpBBTree.c:760:38: note: in expansion of macro ‘cpcalloc’
  760 |         cpFloat *bounds = (cpFloat *)cpcalloc(count*2, sizeof(cpFloat));
      |                                      ^~~~~~~~
In file included from /home/usuario/cpp_libraries/Chipmunk-7.0.3/src/cpBBTree.c:22:
/usr/include/stdlib.h:675:14: note: in a call to allocation function ‘calloc’ declared here
  675 | extern void *calloc (size_t __nmemb, size_t __size)
      |              ^~~~~~
[ 38%] Building C object src/CMakeFiles/chipmunk_static.dir/cpBBTree.c.o
In file included from /home/usuario/cpp_libraries/Chipmunk-7.0.3/include/chipmunk/chipmunk_private.h:25,
                 from /home/usuario/cpp_libraries/Chipmunk-7.0.3/src/cpBBTree.c:25:
/home/usuario/cpp_libraries/Chipmunk-7.0.3/src/cpBBTree.c: In function ‘partitionNodes’:
/home/usuario/cpp_libraries/Chipmunk-7.0.3/include/chipmunk/chipmunk.h:72:26: warning: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
   72 |         #define cpcalloc calloc
/home/usuario/cpp_libraries/Chipmunk-7.0.3/src/cpBBTree.c:760:38: note: in expansion of macro ‘cpcalloc’
  760 |         cpFloat *bounds = (cpFloat *)cpcalloc(count*2, sizeof(cpFloat));
      |                                      ^~~~~~~~
In file included from /home/usuario/cpp_libraries/Chipmunk-7.0.3/src/cpBBTree.c:22:
/usr/include/stdlib.h:675:14: note: in a call to allocation function ‘calloc’ declared here
  675 | extern void *calloc (size_t __nmemb, size_t __size)
      |              ^~~~~~

I also had to copy the file /usr/include/linux/sysctl.h to /usr/include/sys/sysctl.h , because it would not build properly otherwise. After building, i executed the chipmunk_demos program and it seems that most of the demos instantly freeze when two bodies collide, having to Ctrl-C the program to be able to close it. The terminal also doesn't show any warnings or errors at the moment of freezing, it just seems to silently crash.

I tried clearing the built files with make clean and then rebuilding, but as expected nothing changed. The warnings might suggest it has to do something with memory, but I have no idea how to fix it or if I'm going to have to edit most of the files to do so. Is the install just broken somehow?

Edit: This text also appears in the terminal when the program is executed. Seems to be only errors related to the GUI and such and therefore probably not related to the crash, but I'm putting them out there just in case:

MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745284701a294317.html

最新回复(0)