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

Author Topic: Runs in debug but not release (fails to create window)  (Read 4095 times)

0 Members and 1 Guest are viewing this topic.

JudgeWargrave

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Runs in debug but not release (fails to create window)
« on: January 13, 2017, 06:15:26 pm »
I'm running Windows 10. SFML 2.4.1. Dynamic linking. I'm building with Visual Studio 2015.

My game builds, both in debug and release, and runs exactly as expected in debug. However, when running the release .exe, I get the message: "The program can't start because sfml-window-d-2.dll is missing from your computer." The same message regarding sfml-system-d-2.dll pops up twice as well. This immediately seems strange because although these .dlls aren't in the folder with the .exe, they are the debug versions so they shouldn't be needed, right?

If I oblige the message and move the -d versions into the folder, the game crashes at the point the window would be created:

std::cout << "creating window...";
window.create(sf::VideoMode(LOCAL_INITIAL_RES.x, LOCAL_INITIAL_RES.y), NAME);
std::cout << "...created window" << std::endl;
 

This same code is passed over without error in debug.

If I click the debug option after the crash, Visual Studio opens xutility at line 166 and gives a read access violation: "_Parent_proxy was 0xFFFFFFFF".

The project properties seem to be correct.

Any ideas what could be going wrong here?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Runs in debug but not release (fails to create window)
« Reply #1 on: January 13, 2017, 08:49:50 pm »
Do you link the debug libs in release mode?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Runs in debug but not release (fails to create window)
« Reply #2 on: January 14, 2017, 01:30:34 am »

sfml-window-d-2.dll 

that d means debug

so that dll is for the debug version of the exe

as eX said, you've got the debug versions of the dll linked with the release version of the exe

see
http://www.sfml-dev.org/tutorials/2.4/start-vc.php

where it says
It is important to link to the libraries that match the configuration: "sfml-xxx-d.lib" for Debug, and "sfml-xxx.lib" for Release. A bad mix may result in crashes.

JudgeWargrave

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Runs in debug but not release (fails to create window)
« Reply #3 on: January 14, 2017, 04:21:00 pm »
In the project properties under Linker>Input, the additional directories are openal32.lib, sfml-system.lib, sfml-window.lib, sfml-graphics.lib, and sfml-audio.lib. This is in release configuration. In debug configuration I have sfml-system-d.lib, sfml-window-d.lib, sfml-graphics-d.lib, sfml-audio-d.lib. So I believe I have the right libraries linked.

Edit: Just to see if it would have any effect, I tried switching to static linking, and it works in both debug and release in that case. So in a practical sense the problem is solved, but I'm still curious why only the dynamic release version has a problem. It seems like it must be a problem with the libraries like you two said, but it's odd because I must have been linking the right ones, since I just changed the file names to -s and it works. Maybe something went wrong with the sfml-xxx.libs or .dlls specifically and redownloading them would fix it.
« Last Edit: January 14, 2017, 06:12:07 pm by JudgeWargrave »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Runs in debug but not release (fails to create window)
« Reply #4 on: January 14, 2017, 06:06:15 pm »
Well if the application asks for sfml-system-d-2.dll, then you're linking sfml-system-d.lib somewhere.
Try to dig deeper or create a new project and pay attention to what you're adding where. Also make sure to check the general configuration settings.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/