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

Author Topic: Linker error at sf::Time  (Read 5126 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Linker error at sf::Time
« on: January 21, 2012, 12:53:01 am »
Using Visual Studio 2010, I get strange linker errors when I compile the SFML Network module with dynamic (DLL) configuration.
Code: [Select]
3>Ftp.obj : error LNK2001: Unresolved external symbol ""public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)".
3>SocketSelector.obj : error LNK2001: Unresolved external symbol ""public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)".
3>TcpSocket.obj : error LNK2001: Unresolved external symbol ""public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)".

I don't see a mistake in the code, sf::Time has the SFML_API macro, and Zero is properly defined in Time.cpp. If I interpret the Dependency Walker output correctly, this symbol is exported in sfml-system-d-2.dll. With MinGW/g++, SFML compiles fine.

Can anybody confirm this? I've also found a similar problem on StackOverflow...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Linker error at sf::Time
« Reply #1 on: January 21, 2012, 02:07:18 am »
I just updated my copy from git and I get that same error from sfml-network and this one from sfml-audio:

Code: [Select]
SoundStream.obj : error LNK2019: unresolved external symbol "public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B) referenced in function "private: bool __thiscall sf::SoundStream::FillAndPushBuffer(unsigned int)" (?FillAndPushBuffer@SoundStream@sf@@AAE_NI@Z)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Linker error at sf::Time
« Reply #2 on: January 21, 2012, 10:37:01 am »
It's fixed, thanks for the quick feedback.

On a side note, it also answers a question that I've always asked to myself (-> how it could work with a single export macro for all modules) :)
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Linker error at sf::Time
« Reply #3 on: January 21, 2012, 10:53:52 am »
Thank you for the fast fix! :)

I didn't expect it to be that complex. If I understand correctly, you now use __declspec(dllexport) only for the currently compiled module, and __declspec(dllimport) for modules on which the current one depends.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Linker error at sf::Time
« Reply #4 on: January 21, 2012, 11:36:45 am »
Quote
If I understand correctly, you now use __declspec(dllexport) only for the currently compiled module, and __declspec(dllimport) for modules on which the current one depends.

Correct ;)
Laurent Gomila - SFML developer

 

anything