|
BuildingfromSource
Building from SourceLinuxTo compile the latest SVN version, follow these steps:
If you are using Ubuntu, you can install it via Synaptic Package Manager (package name 'swig'). You will also need to install the python-dev package, and build-essential (and python-pygame if you want to run the testbed).sudo apt-get install build-essential python-dev swig python-pygame subversion svn checkout http://pybox2d.googlecode.com/svn/trunk/ pybox2d python setup.py build # Assuming everything goes well... sudo python setup.py install --force ErrorsOld versions of setuptoolsIf you see an error like this: File "/usr/lib/python2.6/distutils/command/build_ext.py", line 460, in
build_extension
ext_path = self.get_ext_fullpath(ext.name)
File "/usr/lib/python2.6/distutils/command/build_ext.py", line 633, in
get_ext_fullpath
filename = self.get_ext_filename(modpath[-1])
File "build/bdist.linux-i686/egg/setuptools/command/build_ext.py", line
85, in get_ext_filename
KeyError: '_Box2D'Upgrade your setuptools version. 'setup.py' has been patched in the pybox2d branch for the upcoming 2.1.0 release, but not for the trunk (2.0.2 series). 64-bit LinuxBuilding from the 2.0.2b1 source release, there will be errors like: Box2D/Box2D_wrap.cpp:3528: error: cast from b2Joint* to int32* loses precision This issue was fixed soon after the release, but it was never repackaged for another release. If you update the individual files found in this SVN version and recompile, you'll have a mostly identical copy to 2.0.2b1, just with a few additional setters. If you don't care about having perfect 2.0.2b1 compatibility, try building from the latest SVN instead. Windows
[build] compiler=mingw32 [build_ext] compiler=mingw32 svn checkout http://pybox2d.googlecode.com/svn/trunk/ pybox2d cd /c/path/to/pybox2d/Box2D setup.py build setup.py install --force OS XDependenciesTo build pybox2d, you will need:
Install Apple Developer Tools
SWIG Installation
cd ~/Desktop tar -zxf swig-*.tar.gz cd swig-* ./configure make sudo make install <ENTER THE ADMINISTRATOR/ROOT PASSWORD> pybox2d Installation
cd ~/Desktop unzip Box2D-*.zip cd Box2D-*/ python setup.py build If all went well,sudo python setup.py install --force <ENTER THE ADMINISTRATOR/ROOT PASSWORD>Close the Terminal.app window and see the links on the project home page for the testbed and documentation. OS X Snow Leopard / 64-bit InstallationsBuilding from the 2.0.2b1 source release, there will be errors like: Box2D/Box2D_wrap.cpp:3528: error: cast from b2Joint* to int32* loses precision This issue was fixed soon after the release, but it was never repackaged for another release. If you update the individual files found in this SVN version and recompile, you'll have a mostly identical copy to 2.0.2b1, just with a few additional setters. If you don't care about having perfect 2.0.2b1 compatibility, try building from the latest SVN instead (see the next section). Building pybox2d from the SVNThis is only necessary if you want the latest features that pybox2d has to offer. Follow the above headings Install Apple Developer Tools and SWIG Installation. Now follow the steps 2 and beyond for Linux. | |
running build running build_py copying ./Box2D.py -> build/lib.linux-i686-2.5/Box2D running build_ext building 'Box2D._Box2D' extension swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp swig -python -c++ -IBox2D -O -includeall -ignoremissing -w201 -outdir . -o Box2D/Box2D_wrap.cpp Box2D/Box2D.i gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c Box2D/Box2D_wrap.cpp -o build/temp.linux-i686-2.5/Box2D/Box2D_wrap.o -I. cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ Box2D/Box2D_wrap.cpp:140:20: error: Python.h: No such file or directory Box2D/Box2D_wrap.cpp:3092:4: error: #error "This python version requires swig to be run with the '-classic' option" Box2D/Box2D_wrap.cpp:3096:3: error: #error "This python version requires swig to be run with the '-nomodern' option" Box2D/Box2D_wrap.cpp:3099:3: error: #error "This python version requires swig to be run with the '-nomodernargs' option" Box2D/Box2D_wrap.cpp:3102:3: error: #error "This python version requires swig to be run with the '-nofastunpack' option" Box2D/Box2D_wrap.cpp:746: error: expected initializer before ‘*’ token Box2D/Box2D_wrap.cpp:801: error: expected initializer before ‘*’ token Box2D/Box2D_wrap.cpp:822: error: expected initializer before ‘*’ token In file included from /usr/include/c++/4.3/new:45, from /usr/include/c++/4.3/ext/new_allocator.h:37, from /usr/include/c++/4.3/i486-linux-gnu/bits/c++allocator.h:39, from /usr/include/c++/4.3/bits/allocator.h:53, from /usr/include/c++/4.3/string:48, from Box2D/Box2D_wrap.cpp:2511: /usr/include/c++/4.3/exception:40: error: expected declaration before end of line error: command 'gcc' failed with exit status 1 Python 2.5.2 SWIG Version 1.3.35 gcc (Ubuntu 4.3.2-1ubuntu12) 4.3.2ntzaperas, do you have the python-dev package installed? It doesn't look like gcc is able to find it -- see the first error:
Hi!.. awesome job with this wrapper!.. but I found a blocking error when trying to install it on a 64bit linux:
I managed to work around this by replacing int32 with unsigned long.. but I'm not 100% sure whether it causes undesired side effects.
Hi piratiss, Thanks for the comment. The 64bit error you mentioned should have been already fixed in the latest SVN.
Hello,
I had the same problem as piratiss. I just want to confirm that it has been fixed at the latest SVN build.
I had the same problems as ntzaperas, which was fixed when I installed the python-dev package.
There is still a lot of warnings, mostly this one
Compiled successfully, but
$ python Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57) [GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Box2D Traceback (most recent call last): File "<stdin>", line 1, in <module> File "Box2D.py", line 28, in <module> _Box2D = swig_import_helper() File "Box2D.py", line 20, in swig_import_helper import _Box2D ImportError: No module named _Box2D >>>akirosspower,
Have you tried changing directories outside of the pybox2d source's? For example, try to load it up when running Python in your home directory.
Oh gosh, you were right! I didn't notice my working directory was the same :S Thanks :) Sorry