Question

So this is a common error but all the posts say I need to pay more attention to which versions of libraries I'm including. I'm using SDL2, OpenGL, and SDL_Mixer... I don't have any options in what I include except to stick with 32-bit libs.

Debug compiles fine but release gives me the LNK2005 error unless I set runtime libraries to /MD. I'd like to avoid that extra dependency. The resulting executable stops responding on SDL initializations or some OpenGL calls unless Visual Studio launches the release build. So I've got some kind of multi-threading issue but I'm not close to understanding it. Little help?

UPDATE: /FORCE:MULTIPLE allows the project to be compiled with /MT. But just like with /MD, the resulting executable crashes unless visual studio launches the release build. What does that mean?

UPDATE2: Use /MD in SDL projects. Crash was just a memory error the debugger wasn't catching. Linking was unrelated.

Was it helpful?

Solution

Ok, so your only other options I see are

(1) ignoring the other library that is causing the LNK2005 error (since you are defining something in two places, it doesn't know which one to use. Since ignoring libcmt.lib caused a lot of issues, maybe try the other place that defines the method).

2) Use /FORCE:MULTIPLE in your linker command line options, which will have it allow multiple definitions of a symbol.

OTHER TIPS

Is rebuilding SDL an option? If so

  • get the source from libsdl.org
  • go to the VisualC directory
  • select the relevant solution
  • from there, for each of the projects, change the build type from /MD to /MT
  • rebuild: you should now just get a lib and DLL which are built as /MT and should link with your program compiled as /MT. You should no longer have to resort to /ignorelibs and /forcemultiple
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top