SFML community forums

Help => General => Topic started by: Zeleska on November 25, 2019, 11:47:20 pm

Title: Only wish to confirm: Does SFML static linking runtime is MDd in Visual Studio?
Post by: Zeleska on November 25, 2019, 11:47:20 pm
    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?
Title: Re: Only wish to confirm: Does SFML static linking runtime is MDd in Visual Studio?
Post by: eXpl0it3r on November 26, 2019, 12:35:52 am
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.
Title: Re: Only wish to confirm: Does SFML static linking runtime is MDd in Visual Studio?
Post by: Zeleska on November 26, 2019, 01:53:20 am
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?
Title: Re: Only wish to confirm: Does SFML static linking runtime is MDd in Visual Studio?
Post by: eXpl0it3r on November 26, 2019, 07:46:22 am
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.
Title: Re: Only wish to confirm: Does SFML static linking runtime is MDd in Visual Studio?
Post by: Zeleska on November 26, 2019, 08:51:18 pm
I solved things yesterday, my project runs now. And thank you for the advice :)