Search code examples
c++opengldllglfwmicrosoft-runtime-library

LNK4098 - 'MSVCRT' conflict using GLFW


I'm working on a project using OpenGL. However, I have the linker warning "Resolving LNK4098: defaultlib 'MSVCRT' conflicts with ..." when I build my project.

I've been reading a lot of stuff about this warning, and found out using Dependency Walker that my GLEW is using MSVCRT.dll (I think that's how it's supposed to be, since that's the "default lib"). However, when I inspect GLFW3.DLL it says it uses MSVCR120.DLL, the wrong dll which I suspect to cause the conflict in my application.

So I try to build GLFW from scratch with the source code from the website. I edited the following settings in the project:

  • Target Extension -> first I build the .lib, then the .dll
  • Platform Toolset -> v120
  • Configuration type -> first I build the .lib, then the .dll

And then under C/C++ -> Code Generation -> Runtime Library I select Multi-threaded DLL (/MD)

Before I compile I put everything on "release".

When I rebuild everything and inspect it again, It still says it's using MSVCR120.dll and it still causes the well known LNK4098 conflict. What am I doing wrong here? How can I resolve the conflict? Thanks in advance!


Solution

  • You need to use the same "Runtime Library" setting for the library and your application.

    To avoid problems, you should prepare two builds of the library: one for debug and one for release.