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

Troubles building with python3.5 #61

Closed iago-lito closed 8 years ago

iago-lito commented 8 years ago

Here is how I have tried to build the module:

git clone https://github.com/bastienleonard/pysfml-cython
cd pysfml-cython/
cd src/
cython -3 --cplus sfml.pyx
cd ..
sudo python3.5 setup3k.py build_ext  # error: command 'gcc' failed with exit status 1
./patch.py
sudo python3.5 setup3k.py build_ext # fails again

Here is the output of the last command:

running build_ext
skipping 'src/sfml.cpp' Cython extension (up-to-date)
building 'sfml' extension
gcc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python3.5m -c src/sfml.cpp -o build/temp.linux-x86_64-3.5/src/sfml.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from src/sfml.cpp:260:0:
src/hacks.hpp:84:26: error: conflicting return type specified for ‘virtual unsigned int CppShape::getPointCount() const’
     virtual unsigned int getPointCount() const;
                          ^
In file included from /usr/local/include/SFML/Graphics/CircleShape.hpp:32:0,
                 from /usr/local/include/SFML/Graphics.hpp:34,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/Shape.hpp:196:25: error:   overriding ‘virtual std::size_t sf::Shape::getPointCount() const’
     virtual std::size_t getPointCount() const = 0;
                         ^
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_5Glyph_6bounds___get__(__pyx_obj_4sfml_Glyph*)’:
src/sfml.cpp:26173:13: error: no match for ‘operator=’ (operand types are ‘sf::IntRect {aka sf::Rect<int>}’ and ‘sf::FloatRect {aka sf::Rect<float>}’)
   __pyx_t_1 = __pyx_v_self->p_this->bounds;
             ^
src/sfml.cpp:26173:13: note: candidate is:
In file included from /usr/local/include/SFML/Graphics/Transform.hpp:32:0,
                 from /usr/local/include/SFML/Graphics/RenderStates.hpp:33,
                 from /usr/local/include/SFML/Graphics/Drawable.hpp:32,
                 from /usr/local/include/SFML/Graphics/Shape.hpp:32,
                 from /usr/local/include/SFML/Graphics/CircleShape.hpp:32,
                 from /usr/local/include/SFML/Graphics.hpp:34,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note: sf::Rect<int>& sf::Rect<int>::operator=(const sf::Rect<int>&)
 class Rect
       ^
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note:   no known conversion for argument 1 from ‘sf::FloatRect {aka sf::Rect<float>}’ to ‘const sf::Rect<int>&’
src/sfml.cpp: In function ‘int __pyx_pf_4sfml_5Glyph_6bounds_2__set__(__pyx_obj_4sfml_Glyph*, PyObject*)’:
src/sfml.cpp:26257:32: error: no match for ‘operator=’ (operand types are ‘sf::FloatRect {aka sf::Rect<float>}’ and ‘sf::IntRect {aka sf::Rect<int>}’)
   __pyx_v_self->p_this->bounds = __pyx_v_rect;
                                ^
src/sfml.cpp:26257:32: note: candidate is:
In file included from /usr/local/include/SFML/Graphics/Transform.hpp:32:0,
                 from /usr/local/include/SFML/Graphics/RenderStates.hpp:33,
                 from /usr/local/include/SFML/Graphics/Drawable.hpp:32,
                 from /usr/local/include/SFML/Graphics/Shape.hpp:32,
                 from /usr/local/include/SFML/Graphics/CircleShape.hpp:32,
                 from /usr/local/include/SFML/Graphics.hpp:34,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note: sf::Rect<float>& sf::Rect<float>::operator=(const sf::Rect<float>&)
 class Rect
       ^
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note:   no known conversion for argument 1 from ‘sf::IntRect {aka sf::Rect<int>}’ to ‘const sf::Rect<float>&’
src/sfml.cpp: In function ‘int __pyx_pf_4sfml_5Shape___init__(__pyx_obj_4sfml_Shape*, PyObject*, PyObject*)’:
src/sfml.cpp:38009:72: error: invalid new-expression of abstract class type ‘CppShape’
   __pyx_v_self->__pyx_base.p_this = ((sf::Transformable *)new CppShape());
                                                                        ^
In file included from src/sfml.cpp:260:0:
src/hacks.hpp:79:7: note:   because the following virtual functions are pure within ‘CppShape’:
 class CppShape : public sf::Shape
       ^
In file included from /usr/local/include/SFML/Graphics/CircleShape.hpp:32:0,
                 from /usr/local/include/SFML/Graphics.hpp:34,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/Shape.hpp:213:22: note:    virtual sf::Vector2f sf::Shape::getPoint(std::size_t) const
     virtual Vector2f getPoint(std::size_t index) const = 0;
                      ^
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_12RenderStates_10blend_mode___get__(__pyx_obj_4sfml_RenderStates*)’:
src/sfml.cpp:48479:64: error: invalid cast from type ‘sf::BlendMode’ to type ‘int’
   __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_v_self->p_this->blendMode)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                                ^
src/sfml.cpp: In function ‘int __pyx_pf_4sfml_12RenderStates_10blend_mode_2__set__(__pyx_obj_4sfml_RenderStates*, int)’:
src/sfml.cpp:48550:53: error: no matching function for call to ‘sf::BlendMode::BlendMode(int&)’
   __pyx_v_self->p_this->blendMode = ((sf::BlendMode)__pyx_v_value);
                                                     ^
src/sfml.cpp:48550:53: note: candidates are:
In file included from /usr/local/include/SFML/Graphics.hpp:33:0,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/BlendMode.hpp:107:5: note: sf::BlendMode::BlendMode(sf::BlendMode::Factor, sf::BlendMode::Factor, sf::BlendMode::Equation, sf::BlendMode::Factor, sf::BlendMode::Factor, sf::BlendMode::Equation)
     BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,
     ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:107:5: note:   candidate expects 6 arguments, 1 provided
/usr/local/include/SFML/Graphics/BlendMode.hpp:94:5: note: sf::BlendMode::BlendMode(sf::BlendMode::Factor, sf::BlendMode::Factor, sf::BlendMode::Equation)
     BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Add);
     ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:94:5: note:   candidate expects 3 arguments, 1 provided
/usr/local/include/SFML/Graphics/BlendMode.hpp:81:5: note: sf::BlendMode::BlendMode()
     BlendMode();
     ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:81:5: note:   candidate expects 0 arguments, 1 provided
/usr/local/include/SFML/Graphics/BlendMode.hpp:41:26: note: sf::BlendMode::BlendMode(const sf::BlendMode&)
 struct SFML_GRAPHICS_API BlendMode
                          ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:41:26: note:   no known conversion for argument 1 from ‘int’ to ‘const sf::BlendMode&’
src/sfml.cpp: In function ‘PyObject* PyInit_sfml()’:
src/sfml.cpp:62640:50: error: cannot convert ‘const sf::BlendMode’ to ‘int’ for argument ‘1’ to ‘PyObject* __Pyx_PyInt_From_int(int)’
   __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendAlpha); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                  ^
src/sfml.cpp:62652:48: error: cannot convert ‘const sf::BlendMode’ to ‘int’ for argument ‘1’ to ‘PyObject* __Pyx_PyInt_From_int(int)’
   __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendAdd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                ^
src/sfml.cpp:62664:53: error: cannot convert ‘const sf::BlendMode’ to ‘int’ for argument ‘1’ to ‘PyObject* __Pyx_PyInt_From_int(int)’
   __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendMultiply); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                     ^
src/sfml.cpp:62676:49: error: cannot convert ‘const sf::BlendMode’ to ‘int’ for argument ‘1’ to ‘PyObject* __Pyx_PyInt_From_int(int)’
   __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendNone); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                 ^
src/sfml.cpp: At global scope:
src/sfml.cpp:41551:39: warning: ‘__pyx_obj_4sfml_Vertex* __pyx_f_4sfml_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
 static struct __pyx_obj_4sfml_Vertex *__pyx_f_4sfml_wrap_vertex_instance(sf::Vertex *__pyx_v_p) {
                                       ^

If the build fails, run patch.py and try again
----------------------------------------------

error: command 'gcc' failed with exit status 1 

Have I done anything wrong? A similar thing seems to happen with python3.4 anyway.

I do have SFML installed:

$ sudo ldconfig -p | grepl libsfml
libsfml-window.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-window.so.2.3
libsfml-window.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-window.so.2
libsfml-window.so (libc6,x86-64) => /usr/local/lib/libsfml-window.so
libsfml-system.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-system.so.2.3
libsfml-system.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-system.so.2
libsfml-system.so (libc6,x86-64) => /usr/local/lib/libsfml-system.so
libsfml-network.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-network.so.2.3
libsfml-network.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-network.so.2
libsfml-network.so (libc6,x86-64) => /usr/local/lib/libsfml-network.so
libsfml-graphics.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-graphics.so.2.3
libsfml-graphics.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2
libsfml-graphics.so (libc6,x86-64) => /usr/local/lib/libsfml-graphics.so
libsfml-audio.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-audio.so.2.3
libsfml-audio.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-audio.so.2
libsfml-audio.so (libc6,x86-64) => /usr/local/lib/libsfml-audio.so

During troubleshooting, I would like to use ancient pysfml binding, but I can't download it anymore. How is this repo related to that project? Do you know why is this link dead?

This is it, thank you for this precious binding :)

bastienleonard commented 8 years ago

Hi,

This project hasn't been updated in a few years, so compilation with any recent version of SFML should fail. This seems to be the go-to Python binding now: https://github.com/Sonkun/python-sfml

I recently looked at the state of SFML and it seemed like it wouldn't be too much work to update the binding. However, I'm not sure there is any demand for it.

For the dead link see this issue: https://github.com/Sonkun/python-sfml/issues/124

iago-lito commented 8 years ago

Yeah, I've just noticed now.. Cheers :)