SFML community forums

Help => General => Topic started by: Storngrir on October 12, 2014, 09:58:00 pm

Title: [Solved] Using SFML in own dll
Post by: Storngrir 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.
 
Title: Re: Using SFML in our own engine dll
Post by: Mario 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?
Title: Re: Using SFML in our own engine dll
Post by: Storngrir 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.
Title: Re: Using SFML in our own engine dll
Post by: zsbzsb on October 13, 2014, 06:37:45 pm
Where did you get SFML binaries from?
Title: Re: Using SFML in our own engine dll
Post by: Storngrir on October 13, 2014, 06:39:37 pm
http://www.nightlybuilds.ch/project/show/1/SFML/
Title: Re: Using SFML in our own engine dll
Post by: eXpl0it3r 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?
Title: Re: Using SFML in our own engine dll
Post by: Storngrir 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.
Title: Re: Using SFML in our own engine dll
Post by: MadMartin 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  ;)
Title: Re: Using SFML in own dll
Post by: Storngrir 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?
Title: AW: Using SFML in own dll
Post by: eXpl0it3r on October 16, 2014, 07:13:36 pm
Maybe if you provide a full workspace/solution someone could try to reproduce it.
Title: Re: Using SFML in own dll
Post by: Storngrir 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.