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

Author Topic: Sfml on dynamic dll  (Read 2408 times)

0 Members and 1 Guest are viewing this topic.

roccio

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
    • Email
Sfml on dynamic dll
« on: April 02, 2021, 08:21:44 am »
Hello, I have an sfml exe that should dynamically (using loadlibrary) load a dll that uses sfml too. In the dll there is a base class and are exposed two function to create and destroy an instance of that class. All works, but when I try to do something sfml related like loading textures, I get opengl context errors and nothing works. I linked both (exe and dll) with sfml in a static way.

Any help to get it working?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Sfml on dynamic dll
« Reply #1 on: April 28, 2021, 09:41:26 am »
So to understand this correctly you have the following setup:

Custom dynamic library: Links SFML statically
Executable: Links SFML statically and loads custom library via loadlibrary?

That way you essentially have two different SFML versions now, one as part of your executable and one as part of your dynamic library, this will cause all sorts of issues (since SFML uses some globally shared objects).

If you link SFML dynamically, I think you can avoid at least part of the issue.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

roccio

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
    • Email
Re: Sfml on dynamic dll
« Reply #2 on: April 28, 2021, 09:38:18 pm »
Yes, if loading dynamically all works well. Just curious if this could be done also with static linking.

 

anything