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

Author Topic: Only wish to confirm: Does SFML static linking runtime is MDd in Visual Studio?  (Read 2163 times)

0 Members and 1 Guest are viewing this topic.

Zeleska

  • Newbie
  • *
  • Posts: 5
    • View Profile
    Background
My project uses a C++ GUI library named Nana that only has static linking options, and the runtime options it needs is MTd for debug and MT for release. The GUI is finished, next, I wanted to use sfml's audio module, but since I am already using a library in my project that uses static linking, I tried to link sfml statically.

I finished following the steps in 'Learn' section, but when I try to run the program Visual Studio 2019 says that there is a mistmatch in the RuntimeLibrary value, it seems sfml uses MDd for debug and MD for release in static linking, is this correct or I am doing something wrong? SFML_STATIC is defined in the preprocessor, I did not skip that.

    40% not related question
Does a project that link statically to a library must use the runtime options MTd for debug and MT for release?, is this a law? or it can have the other runtime options MDd and MD respectively?
Can I link statically to a library and dynamically link to other library in the same project? yes or no?
« Last Edit: November 26, 2019, 01:40:06 am by Zeleska »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Yes, SFML's pre-built static binaries for Visual Studio come with /MD or /MDd.

Based on that alone, static libraries can use /MD /MDd, but you can't mix the runtime types in your application. If you want to use one, the all C++ libraries need to use the runtime setting.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Zeleska

  • Newbie
  • *
  • Posts: 5
    • View Profile
Hello eXpl0it3r, thanks for answering. Only one question remains: In a project x, can I statically link to a library and dynamically link to other library in the same project? yes or no?, My conclusion is yes as long as the runtime options are the same for all libraries, is that correct?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
You can, but it's not always a good idea to do so.
For you, I'd recommend to just build SFML with SFML_STATIC_STD_LIB set in CMake.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Zeleska

  • Newbie
  • *
  • Posts: 5
    • View Profile
I solved things yesterday, my project runs now. And thank you for the advice :)

 

anything