SFML community forums

Help => Window => Topic started by: TheCommunistDuck on January 01, 2010, 10:39:25 pm

Title: Inheriting or composing with sf::Window?
Post by: TheCommunistDuck on January 01, 2010, 10:39:25 pm
Hey. I thought it was probably better to separate this from the other topic, seeing as they aren't really related.

I'm trying to make a window for OpenGL, by extending sf::Window (Attach a game loop, and things). However, if I try to do something like this:
Code: [Select]
class GLWindow : public sf::Window
{
//blah blah blah
};


I get linker errors from sfml-window-s.lib, almost all of functions I'm not using:
Code: [Select]
E:\CodeBlocks\...\libsfml-window-s.a(Joystick.o):Joystick.cpp:(.text+0x45)||undefined reference to `_joyGetPosEx@8'|
E:\CodeBlocks\...\libsfml-window-s.a(Joystick.o):Joystick.cpp:(.text+0x78)||undefined reference to `_joyGetPosEx@8'|
||=== Build finished: 30 errors, 0 warnings ===|
// The /.../ is my omittings.


However, if I remove the inheritance from sf::Window, it disappears.
sf::Window does inherit itself from NonCopyable, but I think that only stops foo = nonCopyableBar.

I also have the same problem with composition, if GLWindow has an object of sf::Window.

I think all the libraries are linked fine, but that's the only reason I can think why it isn't working.
It could also be something to do with SFML2, but I think somebody would've picked up on it.

Thanks.
-Mark.
Title: Inheriting or composing with sf::Window?
Post by: Nexus on January 02, 2010, 01:00:37 am
Your problem isn't related to composition or inheritance in particular. The thing is just, that the linker won't search dependencies which aren't used in the code. If you try to instantiate sf::Window in main(), you will probably get the same error.

Concerning your problems, did you recompile SFML? Make sure the right configuration (release and debug/static or DLL) was chosen and your project uses exactly the same settings. And double-check if really all libraries are specified correctly.
Title: Inheriting or composing with sf::Window?
Post by: Laurent on January 02, 2010, 11:52:31 am
If you recompile SFML static libraries for MinGW there is an extra step to include the external dependencies. Just use the batch-build to properly build all the libraries automatically.
Title: Inheriting or composing with sf::Window?
Post by: TheCommunistDuck on January 02, 2010, 12:30:08 pm
I was trying to solve it, and copied the 4.lib files to the MinGW lib/ directory. It now works fine.

Thanks.
-Mark. :D