KeyHeart
KeyHeart

Reputation: 173

How do I link a static library using cl.exe? (Specifying RuntimeLibrary)

cl -MT -DSFML_STATIC main.cpp freetype.lib gdi32.lib glew.lib jpeg.lib openal32.lib opengl32.lib sfml-audio-s.lib sfml-graphics-s.lib sfml-network-s.lib sfml-system-s.lib sfml-window-s.lib sndfile.lib winmm.lib

The result is:

sfml-graphics-s.lib<Color.cpp.obj> : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj

How do I specify the RuntimeLibrary?

Upvotes: 4

Views: 14276

Answers (2)

KeyHeart
KeyHeart

Reputation: 173

If you select MT_StaticRelease in your project settings, any library that you use must use this parameter too. Unfortunately, SFML is compiled with MD_DynamicRelease (the most common and safe choice), so as eXpl0it3r's libraries in /lib. However eXpl0it3r also provides SFML libraries compiled with MT_StaticRelease

Additionally I needed to link user32.lib and advapi32.lib

cl -EHsc -FC -Zi -MT -DSFML_STATIC main.cpp advapi32.lib freetype.lib gdi32.lib glew.lib jpeg.lib openal32.lib opengl32.lib sfml-audio-s.lib sfml-graphics-s.lib sfml-network-s.lib sfml-system-s.lib sfml-window-s.lib sndfile.lib user32.lib winmm.lib

Upvotes: 3

nicebyte
nicebyte

Reputation: 1548

You probably want the multithreaded, dynamic, release version of the runtime library. Use the /MD flag. See here for more information on flags that control which version of runtime library to link against.

The problem is that sfml-graphics-s.lib is linked against the multithreaded, dynamic, release version of the runtime library whereas your command line instructs to link against the multithread, static, release version of that library (you're using the /MT switch). Replace /MT with /MD and the conflict should be resolved.

Upvotes: 1

Related Questions