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

Author Topic: [Solved] Using SFML in own dll  (Read 4672 times)

0 Members and 1 Guest are viewing this topic.

Storngrir

  • Newbie
  • *
  • Posts: 8
    • View Profile
[Solved] Using SFML in own dll
« on: October 12, 2014, 09:58:00 pm »
EDIT: Problem solved. I just remade the visual studio project and checked "empty project" checkbox.
That solved it for me, everything is running fine now.


I want to create my own little game engine on top of SFML. I'm using Visual Studio 2013 and my vs solution is like this:

Solution:
EngineProject: is a DLL project that uses SFML libraries linked statically.
GameProject: is a win32 application that depends on EngineProject.

So basically: SFML->EngineDLL->Game

I've managed to build everything, the engine.dll that uses sfml libs, and game.exe that uses engine.dll, running the SFML example with the little green circle, but when I close the window the application doesn't stop and I need to stop it from task manager. Inside visual studio the same thing happens. Window is closed but application keep running.
 
« Last Edit: October 18, 2014, 03:34:37 am by Storngrir »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Using SFML in our own engine dll
« Reply #1 on: October 13, 2014, 09:33:08 am »
How about debugging, putting a break point in the running process? Just hit the pause button inside visual studio while the program is still running.

Also are you sure you're not mixing different versions of the STL?

Storngrir

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Using SFML in our own engine dll
« Reply #2 on: October 13, 2014, 06:18:43 pm »
I wasn't able to see anything relevant using break points.

Screenshots showing the problem:

Here as you can see everything is running fine
http://puu.sh/caFmN/ada08274c3.png

Now I close the SFML window and application won't finish
http://puu.sh/caFtd/e3164b9d6a.png

Console window is there because I made it appear when running debug.

However if I run release it's the same thing

Running:
http://puu.sh/caFFS/22543942f2.png

Now I close the SFML window:
http://puu.sh/caFHA/19d04a7787.png

As you can see It keeps running in background but doing nothing and without using system resources at all.

If I build the project and run standalone without visual studio when I close the window you can see game.exe is still running and showing up on task manager.
« Last Edit: October 13, 2014, 06:37:35 pm by Storngrir »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Using SFML in our own engine dll
« Reply #3 on: October 13, 2014, 06:37:45 pm »
Where did you get SFML binaries from?
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Storngrir

  • Newbie
  • *
  • Posts: 8
    • View Profile

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Using SFML in our own engine dll
« Reply #5 on: October 13, 2014, 07:28:56 pm »
Honestly, if you don't know what you're doing, don't mix static and dynamic. If you do anyways, you're pretty much on your own. ;D

Which version of the SFML libs (the ones in lib or the ones in lib/static-std) did you link statically against?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Storngrir

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Using SFML in our own engine dll
« Reply #6 on: October 14, 2014, 07:45:16 pm »
Honestly, if you don't know what you're doing, don't mix static and dynamic. If you do anyways, you're pretty much on your own. ;D

Which version of the SFML libs (the ones in lib or the ones in lib/static-std) did you link statically against?

Sorry but as far as I know I'm doing it as supposed. Laurent said that it can be done here: http://en.sfml-dev.org/forums/index.php?topic=11824.0

Even linking all dynamically the same thing happens.
If I set up my engine dll to link sfml dynamically same thing happens.
I think that when SFML runs from a dll it doesn't finish all the threads properly and the application keeps running.

I want to create a mini engine along with my game because I want to reuse the engine later.
If I setup SFML with my game project directly everything works as expected but I need to setup as mentioned before.

So if anybody can help solving this issue would be amazing.

MadMartin

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
Re: Using SFML in our own engine dll
« Reply #7 on: October 14, 2014, 10:36:18 pm »
I want to create a mini engine along with my game because I want to reuse the engine later.
You can reuse the engine without going down into the "DLL hell". It is simply not necessary. Just write your engine, use a namespace and place the files in a separate directory. In your game project, just include them from that directory. With the namespace, you have a fine and nice separation without the DLL hassle.


If I setup SFML with my game project directly everything works as expected but I need to setup as mentioned before.
What do you mean by "I need to setup as mentioned before"? Where stems the necessity from? Is it necessary because you think it is or because you experienced a major obstacle that could only be solved by placing your engine in a separate dll?
In my experience, there is no possible outcome that justifies countless hours wasted with Visual Studio DLL project settings. Even more, if those hours could be used to write a great game  ;)

Storngrir

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Using SFML in own dll
« Reply #8 on: October 16, 2014, 06:38:22 pm »
What if I want to develop the engine along with my game and a level editor for my game? How can I manage to do that? That's why I need to make a dll with sfml.
Seriously? no one has an answer?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Using SFML in own dll
« Reply #9 on: October 16, 2014, 07:13:36 pm »
Maybe if you provide a full workspace/solution someone could try to reproduce it.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Storngrir

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Using SFML in own dll
« Reply #10 on: October 18, 2014, 03:33:39 am »
Problem solved. I just remade the visual studio project and checked "empty project" checkbox.
That solved it for me, everything is running fine now.

 

anything