Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Inheriting or composing with sf::Window?  (Read 1747 times)

0 Members and 1 Guest are viewing this topic.

TheCommunistDuck

  • Newbie
  • *
  • Posts: 11
    • View Profile
Inheriting or composing with sf::Window?
« 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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6276
  • Thor Developer
    • View Profile
    • Bromeon
Inheriting or composing with sf::Window?
« Reply #1 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Inheriting or composing with sf::Window?
« Reply #2 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.
Laurent Gomila - SFML developer

TheCommunistDuck

  • Newbie
  • *
  • Posts: 11
    • View Profile
Inheriting or composing with sf::Window?
« Reply #3 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