bastienleonard / pysfml-cython

A Python 2/3 binding for SFML 2, written with Cython
http://pysfml2-cython.readthedocs.org/
Other
68 stars 8 forks source link

Can't build for Python3 #17

Closed L-P closed 12 years ago

L-P commented 12 years ago

I followed the instructions and it failed for Python3, building for Python2 seems to work fine.

Here is the log :

[2123:0]@leo-laptop:src$ /home/leo/Documents/src/Cython-0.15.1/cython.py --cplus sf.pyx 
[2124:0]@leo-laptop:src$ cd ..
[2125:0]@leo-laptop:pysfml2-cython$ py setup3k.py build_ext
running build_ext
building 'sf' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python3.2mu -c src/sf.cpp -o build/temp.linux-x86_64-3.2/src/sf.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_9Transform_6matrix___get__(PyObject*)’:
src/sf.cpp:7551:8: warning: variable ‘__pyx_v_i’ set but not used [-Wunused-but-set-variable]
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Chunk_7samples___get__(PyObject*)’:
src/sf.cpp:13662:10: warning: variable ‘__pyx_v_i’ set but not used [-Wunused-but-set-variable]
src/sf.cpp: At global scope:
src/sf.cpp:26578:37: warning: ‘__pyx_obj_2sf_Vertex* __pyx_f_2sf_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python3.2mu -c src/hacks.cpp -o build/temp.linux-x86_64-3.2/src/hacks.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
In file included from src/hacks.cpp:30:0:
src/sf.h:15:32: error: expected constructor, destructor, or type conversion before ‘set_error_message’
src/sf.h:16:40: error: expected constructor, destructor, or type conversion before ‘convert_to_vector2f’
src/sf.h:17:53: error: expected constructor, destructor, or type conversion before ‘*’ token
src/sf.h:18:54: error: expected constructor, destructor, or type conversion before ‘*’ token
src/sf.h:19:61: error: expected constructor, destructor, or type conversion before ‘*’ token
src/sf.h:20:61: error: expected constructor, destructor, or type conversion before ‘*’ token
src/hacks.cpp: In member function ‘virtual int MyBuff::sync()’:
src/hacks.cpp:103:38: error: ‘set_error_message’ was not declared in this scope
src/hacks.cpp: In member function ‘virtual void CppDrawable::Draw(sf::RenderTarget&, sf::RenderStates) const’:
src/hacks.cpp:137:73: error: ‘wrap_render_target_instance’ was not declared in this scope
src/hacks.cpp:139:37: error: ‘wrap_render_states_instance’ was not declared in this scope
src/hacks.cpp: In member function ‘virtual sf::Vector2f CppShape::GetPoint(unsigned int) const’:
src/hacks.cpp:206:40: error: ‘convert_to_vector2f’ was not declared in this scope
src/hacks.cpp: In member function ‘virtual bool CppSoundStream::OnGetData(sf::SoundStream::Chunk&)’:
src/hacks.cpp:239:69: error: ‘wrap_chunk_instance’ was not declared in this scope
src/hacks.cpp: In member function ‘virtual void CppSoundStream::OnSeek(sf::Time)’:
src/hacks.cpp:277:34: error: ‘wrap_time_instance’ was not declared in this scope
error: command 'gcc' failed with exit status 1

Other infos :

[2155:0]@leo-laptop:~$ py
Python 3.2.2 (default, Sep  5 2011, 21:17:14) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[2155:0]@leo-laptop:~$ uname -a
Linux leo-laptop 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[2156:0]@leo-laptop:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
bastienleonard commented 12 years ago

Yeah, a file generated by Cython (src/sf.h) doesn't compile. It works (at least on GNU/Linux) if you remove the DL_IMPORT macros (but don't remove their argument). Here is the current file, with the modifications: http://pastebin.com/U3sR62ub

L-P commented 12 years ago

It works, thanks. Maybe this should appear in the documentation?

bastienleonard commented 12 years ago

I have been wondering what's the best way to solve this. I have added a patch.py script that will remove the offending macros. However, the setup script automatically generates the sf.h file and then tries to compile it, so it doesn't look like I can patch it automatically. Source released should make it easier for the user.

See the updated documentation: http://pysfml2-cython.readthedocs.org/en/latest/building.html#building-a-python-3-module