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

Author Topic: Properly linking 32-bit debug SFML-provided WinMain?  (Read 1053 times)

0 Members and 2 Guests are viewing this topic.

GregJ7

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Properly linking 32-bit debug SFML-provided WinMain?
« on: December 10, 2024, 05:09:36 pm »
I am following the SFML and Visual Studio tutorial (https://www.sfml-dev.org/tutorials/2.6/start-vc.php) using the 32-bit download of SFML-2.6.2. I want to get rid of the console window, so I changed the Project Settings -> Linker -> System -> SubSystem from "Console (/SUBSYSTEM:CONSOLE" to "Windows (/SUBSYSTEM:WINDOWS)" [1]. This just requires that I provide a WinMain. I am trying to link in one of the sfml-main files, which works fine for the release version (sfml-main.lib), but bad things happen trying to use sfml-main-d.lib.

I get this warning after adding sfml-main-d.lib to the list of additional files to link and compiling:
sfml-main-d.lib(MainWin32.obj) : warning LNK4099: PDB '' was not found with 'sfml-main-d.lib(MainWin32.obj)' or at ''; linking object as if no debug info

I note that SFML\lib\ contains sfml-main.lib and sfml-main-d.lib, but SFML\lib\Debug\ contains sfml-main-d.pdb and sfml-main-s.pdb (SFML\lib\Release\ is empty.)

Since this is a warning, not an error, the .exe is created and when I try to run it, my Malwarebytes Anti-Malware quarantines my .exe due to having the threat MachineLearning/Anomalous.95%.

What am I doing wrong for the debug version?

[1] The expected error after changing the subsystem but not providing a WinMain:
MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

*Note: I've copied the .DLLs into the .exe Release/Debug directories by hand.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11049
    • View Profile
    • development blog
    • Email
Re: Properly linking 32-bit debug SFML-provided WinMain?
« Reply #1 on: December 11, 2024, 12:55:30 pm »
It's a warning that you can ignore. sfml-main doesn't really have debug symbols, since it's just a WinMain() function calling main(), so even if you have the pdb file, it's pretty useless.

False positives with AV software happens and there's no generic way to prevent that.
What's usually recommend is to exclude your code directories from (real-time) scanning, which will not only increase your build time, but also prevent such false positives on your own builds.

So in short, you've done everything right: change the subsystem & link sfml-main(-d)

I note that SFML\lib\ contains sfml-main.lib and sfml-main-d.lib, but SFML\lib\Debug\ contains sfml-main-d.pdb and sfml-main-s.pdb (SFML\lib\Release\ is empty.)
Looks like sfml-main-s.pdb is actually a wrong naming. The sfml-main lib is always a static library, but seems like for release, we didn't remove the -s suffix for the pdb.
« Last Edit: December 11, 2024, 12:57:38 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/