SFML community forums

Help => Graphics => Topic started by: Jiro on November 28, 2014, 07:42:33 pm

Title: X11 multithreading problem
Post by: Jiro on November 28, 2014, 07:42:33 pm
Hi guys I'm trying to write a game under Linux using SFML,
but when trying to run the example on drawing from threads (http://sfml-dev.org/tutorials/2.1/graphics-draw.php#drawing-from-threads) my Xorg keeps throwing errors. when running the sample I get this error:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.

so naturally I looked up how to call XInitThreads as the error mentioned, which appears to be in the header X11/Xlib.h
so I included the X11/Xlib.h header, linked to X11 using -lX11 and tried building again, but this time I get compile errors:
In file included from /usr/include/X11/Xlib.h:44:0,
                 from ../ThisWarWithin/main.cpp:2:
/usr/include/SFML/Window/WindowStyle.hpp:40:9: error: expected identifier before numeric constant
         None       = 0,      ///< No border / title bar (this flag and all others are mutually exclusive)
         ^
/usr/include/SFML/Window/WindowStyle.hpp:40:9: error: expected '}' before numeric constant
/usr/include/SFML/Window/WindowStyle.hpp:40:9: error: expected unqualified-id before numeric constant
In file included from /usr/include/SFML/Window/Window.hpp:35:0,
                 from /usr/include/SFML/Window.hpp:40,
                 from /usr/include/SFML/Graphics.hpp:32,
                 from ../ThisWarWithin/main.cpp:3:
/usr/include/SFML/Window/WindowStyle.hpp:50:1: error: expected declaration before '}' token
 } // namespace sf
 ^

the code the error seems to point to (according to Qt creator) is this part:
enum
    {
        None       = 0,      ///< No border / title bar (this flag and all others are mutually exclusive)
        Titlebar   = 1 << 0, ///< Title bar + fixed border
        Resize     = 1 << 1, ///< Titlebar + resizable border + maximize button
        Close      = 1 << 2, ///< Titlebar + close button
        Fullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive)

        Default = Titlebar | Resize | Close ///< Default window style
    };
the "None" piece in particular. Anyone got any ideas on how to solve this?

EDIT: forgot to mention, I'm using Arch Linux x64 with Gnome version 3.14.1 and my compiler is g++ (GCC) 4.9.1 20140903 (prerelease)
Title: Re: X11 multithreading problem
Post by: Laurent on November 28, 2014, 07:55:45 pm
X11.h must be the last header included in your .cpp file(s), because these smart guys define a macro named "None", which conflicts with SFML's sf::Style::None.
Title: Re: X11 multithreading problem
Post by: Jiro on November 28, 2014, 07:58:03 pm
Thanks for the fast reply, adding it last indeed solved the problem!