0

I am trying to build a project in Visual Studio using static SFML libraries.

I set all the corresponding linker settings and it works: I can build an executable file that runs anywhere on my machine. However, my friends cannot run it: they do not have msvcp140.dll. I do not want to pack extra DLLs with the executable, nor do I want them to install additional run-time libraries on their machines.

So I assume I need to build the project using the "Multi-threaded \MT" setting (As opposed to the "Multi-threaded DLL \MD" setting)

But switching to that option causes several linker errors with the SFML library such as:

LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in Program.obj

I am certain I am using the static SFML libraries and they are linked properly, yet I cannot switch to the \MT setting for full portability. In fact, using the dynamic version of the library allows the \MT setting - which is obviously useless, because now SFML doesn't link statically. Suggestions?

1 Answer 1

1

You're on the right track, you just have to use a version of SFML that's using the same runtime (or build it yourself). Otherwise you'll get a mismatch as detected by the linker.

When invoking CMake, just set the variable SFML_USE_STATIC_STD_LIBS to TRUE, e.g. by running cmake -DSFML_USE_STATIC_STD_LIBS=TRUE . in your build directory for SFML. Then just build as usual.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! Building the libs through CMake solved the issue. Although it felt incomplete what I did: I built the library locally, but only got the some of the .lib files that were included in the direct SFML download. And I could not find the "include directory" at all. Is this normal? And is it okay to mix these .lib files with the other ones?
@JaagupAverin No, you'll get everything in the source download (or repository clone). Just set the CMake variable CMAKE_INSTALL_PREFIX to your preferred installation location, e.g. C:/SFML and then build the install target to get everything the way it is in the download.
Finally figured out how to properly install the build. That settles it for me now. Thanks for the leads.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.