www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Derelict SFML2 - structs are forward referenced

reply Lucien <lucien.perregaux gmail.com> writes:
Hello.

I want to use Derelict-SFML2 to create a simple window.
But when I compile (linked with dub and derelict-util), I have 
the following error:

src/app.d(30,20): Error: variable myproject.main.window no 
definition of struct sfRenderWindow
../../../.dub/packages/derelict-sfml2-3.0.1/source/derelict/sfm
2/graphics.d(56,1): Error: struct derelict.sfml2.graphics.sfRenderWindow
unknown size
src/app.d(31,5): Error: struct sfRenderWindow is forward 
referenced
src/app.d(32,12): Error: struct sfRenderWindow is forward 
referenced
src/app.d(35,16): Error: struct sfRenderWindow is forward 
referenced
src/app.d(38,17): Error: struct sfRenderWindow is forward 
referenced

My code: http://pastebin.com/1svZAB22

Is it a bug in Derelict-SFML2 or want did I do false ?

Hoping that you understood me with my bad English :)
Dec 26 2015
parent reply Rene Zwanenburg <renezwanenburg gmail.com> writes:
On Saturday, 26 December 2015 at 09:48:29 UTC, Lucien wrote:
 Hello.

 I want to use Derelict-SFML2 to create a simple window.
 But when I compile (linked with dub and derelict-util), I have 
 the following error:

 src/app.d(30,20): Error: variable myproject.main.window no 
 definition of struct sfRenderWindow
 ../../../.dub/packages/derelict-sfml2-3.0.1/source/derelict/sfm
2/graphics.d(56,1): Error: struct derelict.sfml2.graphics.sfRenderWindow
unknown size
 src/app.d(31,5): Error: struct sfRenderWindow is forward 
 referenced
 src/app.d(32,12): Error: struct sfRenderWindow is forward 
 referenced
 src/app.d(35,16): Error: struct sfRenderWindow is forward 
 referenced
 src/app.d(38,17): Error: struct sfRenderWindow is forward 
 referenced

 My code: http://pastebin.com/1svZAB22

 Is it a bug in Derelict-SFML2 or want did I do false ?

 Hoping that you understood me with my bad English :)
sfRenderWindow is an opaque struct, so its size is unknown. This means you can only use pointers to them, and any operations on them will have to be done using SFML. So in your code, change sfRenderWindow to sfRenderWindow*. Did you by any chance look at a C++ tutorial for SFML? Derelict binds to the C API so it looks a bit different. To create a window sfRenderWindow_create can be used, so lines 12 + 13 can be replaced by auto window = sfRenderWindow_create(sfVideoMode(200, 200), "SFML works !"); Another example: the function to check if a window is open is sfRenderWindow_isOpen, taking a pointer to an opaque sfRenderWindow struct as first parameter. Due to D's so called UFCS you can call this function in two ways: sfRenderWindow_isOpen(window); // Just like in C window.sfRenderWindow_isOpen(); // Use member-like syntax
Dec 26 2015
parent reply Lucien <lucien.perregaux gmail.com> writes:
On Saturday, 26 December 2015 at 10:39:29 UTC, Rene Zwanenburg 
wrote:
 On Saturday, 26 December 2015 at 09:48:29 UTC, Lucien wrote:
 Hello.

 I want to use Derelict-SFML2 to create a simple window.
 But when I compile (linked with dub and derelict-util), I have 
 the following error:

 src/app.d(30,20): Error: variable myproject.main.window no 
 definition of struct sfRenderWindow
 ../../../.dub/packages/derelict-sfml2-3.0.1/source/derelict/sfm
2/graphics.d(56,1): Error: struct derelict.sfml2.graphics.sfRenderWindow
unknown size
 src/app.d(31,5): Error: struct sfRenderWindow is forward 
 referenced
 src/app.d(32,12): Error: struct sfRenderWindow is forward 
 referenced
 src/app.d(35,16): Error: struct sfRenderWindow is forward 
 referenced
 src/app.d(38,17): Error: struct sfRenderWindow is forward 
 referenced

 My code: http://pastebin.com/1svZAB22

 Is it a bug in Derelict-SFML2 or want did I do false ?

 Hoping that you understood me with my bad English :)
sfRenderWindow is an opaque struct, so its size is unknown. This means you can only use pointers to them, and any operations on them will have to be done using SFML. So in your code, change sfRenderWindow to sfRenderWindow*. Did you by any chance look at a C++ tutorial for SFML? Derelict binds to the C API so it looks a bit different. To create a window sfRenderWindow_create can be used, so lines 12 + 13 can be replaced by auto window = sfRenderWindow_create(sfVideoMode(200, 200), "SFML works !"); Another example: the function to check if a window is open is sfRenderWindow_isOpen, taking a pointer to an opaque sfRenderWindow struct as first parameter. Due to D's so called UFCS you can call this function in two ways: sfRenderWindow_isOpen(window); // Just like in C window.sfRenderWindow_isOpen(); // Use member-like syntax
Thank you. I've this code now: ---------- sfRenderWindow* win = sfRenderWindow_create(sfVideoMode(200, 200), "SFML works !", 0, null); sfEvent* event; while (win.sfRenderWindow_isOpen()) { while (win.sfRenderWindow_pollEvent(event)) { if (event.type == sfEvtClosed) win.sfRenderWindow_close(); } } --------- But when compiling I got this error: derelict.util.exception.SymbolLoadException ../../../.dub/packages/derelict-util-2.0.4/source/derelict/u il/exception.d(35): Failed to load symbol sfJoystick_getIdentification from shared library libcsfml-window.so Any ideas ?
Dec 26 2015
parent reply drug <drug2004 bk.ru> writes:
26.12.2015 15:34, Lucien пишет:
 On Saturday, 26 December 2015 at 10:39:29 UTC, Rene Zwanenburg wrote:
 On Saturday, 26 December 2015 at 09:48:29 UTC, Lucien wrote:
 Hello.

 I want to use Derelict-SFML2 to create a simple window.
 But when I compile (linked with dub and derelict-util), I have the
 following error:

 src/app.d(30,20): Error: variable myproject.main.window no definition
 of struct sfRenderWindow
 ../../../.dub/packages/derelict-sfml2-3.0.1/source/derelict/sfml2/graphics.d(56,1):
 Error: struct derelict.sfml2.graphics.sfRenderWindow unknown size
 src/app.d(31,5): Error: struct sfRenderWindow is forward referenced
 src/app.d(32,12): Error: struct sfRenderWindow is forward referenced
 src/app.d(35,16): Error: struct sfRenderWindow is forward referenced
 src/app.d(38,17): Error: struct sfRenderWindow is forward referenced

 My code: http://pastebin.com/1svZAB22

 Is it a bug in Derelict-SFML2 or want did I do false ?

 Hoping that you understood me with my bad English :)
sfRenderWindow is an opaque struct, so its size is unknown. This means you can only use pointers to them, and any operations on them will have to be done using SFML. So in your code, change sfRenderWindow to sfRenderWindow*. Did you by any chance look at a C++ tutorial for SFML? Derelict binds to the C API so it looks a bit different. To create a window sfRenderWindow_create can be used, so lines 12 + 13 can be replaced by auto window = sfRenderWindow_create(sfVideoMode(200, 200), "SFML works !"); Another example: the function to check if a window is open is sfRenderWindow_isOpen, taking a pointer to an opaque sfRenderWindow struct as first parameter. Due to D's so called UFCS you can call this function in two ways: sfRenderWindow_isOpen(window); // Just like in C window.sfRenderWindow_isOpen(); // Use member-like syntax
Thank you. I've this code now: ---------- sfRenderWindow* win = sfRenderWindow_create(sfVideoMode(200, 200), "SFML works !", 0, null); sfEvent* event; while (win.sfRenderWindow_isOpen()) { while (win.sfRenderWindow_pollEvent(event)) { if (event.type == sfEvtClosed) win.sfRenderWindow_close(); } } --------- But when compiling I got this error: derelict.util.exception.SymbolLoadException ../../../.dub/packages/derelict-util-2.0.4/source/derelict/util/exception.d(35): Failed to load symbol sfJoystick_getIdentification from shared library libcsfml-window.so Any ideas ?
You have old version of libcsfml that lacks of symbol sfJoystick_getIdentification. Try another version, may be build it from sources to have the newest one.
Dec 26 2015
parent Lucien <lucien.perregaux gmail.com> writes:
On Saturday, 26 December 2015 at 12:47:51 UTC, drug wrote:
 You have old version of libcsfml that lacks of symbol 
 sfJoystick_getIdentification. Try another version, may be build 
 it from sources to have the newest one.
Indeed, the sfml library in the ubuntu repository isn't up-to-date. Thanks for your help.
Dec 26 2015