• 9
• 10
• 9
• 10
• 10

# Project is missing SDL_mixer.h; I add it and the compiler gives 77 errors

This topic is 745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So I'm compiling this program from Jazon Yamamoto's book and it requires SDL_TTF, SDL_Mixer and SDL_Image. I added TTF and Image but when I add SDL_mixer.h the Visual Studio compiler goes mental and throws 77 errors and 1 warning. Every error is "unresolved external symbol" and the warning says this:

Warning 1 warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library C:\Users\Jeff\Documents\object_project\objectproject\objectproject\MSVCRTD.lib(cinitexe.obj) objectproject

It tells me to use /nodefaultlib:library but what the heck is that? Do I replace the words "library" or do I input that parameter verbatim? I don't understand how the compiler complains about one thing, then I add what it wants, and it gives 77 warnings. It's so stupid! I have sympathy for people who try programming and give up. The errors make no sense. Before anybody asks, yes I can reproduce this problem over-and-over again. I want to know how to fix it.

I guess this error has something to do with Microsoft's stupidity in making Visual Studio. I think maybe I can kill off msvcrt.lib and there will be no conflict. Should I do it?

Edit: I used /nodefaultlib under "linker > commandline" and now I get 203 errors. Fantastic.

Edit 2: I used /verbose:lib /NODEFAULTLIB:msvcrt.lib and it killed the warning, however I still get 76 errors.

Edited by jeffkiwi

##### Share on other sites

Sounds like you included the .h file, but did not link the library file/dll.

The compiler complains about more stuff when you attempt to fix the original problem for a very good reason -- until you added the missing file, it didn't know the other errors existed.

If I hand you a book and tell you to proof-read it, but it turns out every page is blank, you give me a single error: "Hey, all text is missing or invisible or something."

Then I fix that and give you a new copy of the book. This time you find loads of spelling errors, and you report them to me. I don't complain and say "Hey, why didn't you tell me about this the last time?"

There's no way you could have known about them until I corrected the initial errors.

##### Share on other sites

I've had mixer.dll in the project folder the whole time. I added SDL_mixer.lib to sdl's LIB directory and I tell Visual Studio to include it as an additional dependency and it still gives 76 errors.

##### Share on other sites

I've had mixer.dll in the project folder the whole time. I added SDL_mixer.lib to sdl's LIB directory and I tell Visual Studio to include it as an additional dependency and it still gives 76 errors.

Going by this tutorial, the names/files you're using are wrong.

Try going through the linked tutorial step by step. If compilation still fails, post some screenshots of the various screens (same as in the tutorial), so we can compare and hunt down the problem.

EDIT: Per the tutorial, step 11 seems to be where something's wrong.

Edited by Lactose!

##### Share on other sites

I've had mixer.dll in the project folder the whole time. I added SDL_mixer.lib to sdl's LIB&amp;nbsp;directory and I&amp;nbsp;tell Visual Studio to include it as an additional dependency and it still gives 76 errors.

Are you telling MSVC to actually link it or have you just specified it as a dependency?

It tells me to use /nodefaultlib:library but what the heck is that? Do I replace the words "library" or do I input that parameter verbatim? I don't understand how the compiler complains about one thing, then I add what it wants, and it gives 77 warnings. It's so stupid! I have sympathy for people who try programming and give up. The errors make no sense. Before anybody asks, yes I can reproduce this problem over-and-over again. I want to know how to fix it.

I guess this error has something to do with Microsoft's stupidity in making Visual Studio. I think maybe I can kill off msvcrt.lib and there will be no conflict. Should I do it?

A library you are trying to link was compiled with a different MSVC runtime than the one the rest of your project is using. This could be a different version or a conflict between dynamic/static or debug/release runtimes. You need to download a version which matches your build system or build it yourself using the adequate compile time options.

##### Share on other sites

I've followed the Lazy Foo tutorial and added the 2 items I was missing - both items are in my SDL/lib/x86 folder.

@BitMaster I just specified it as a dependency. Do I need to go to Command Line to make a link?

All the libraries I'm using are from the SDL website. I tried to build with different runtime library options and no luck.

##### Share on other sites

Instead of putting in various commands from the internet into the command line options, perhaps it would be better if I built SDL_mixer from source. Would that generate a compatible .lib file?

##### Share on other sites
I've used /NODEFAULTLIB extensively, blocking specific default libraries to make the build work with my runtime settings, and I've used /NODEFAULTLIB on its own to block all default libraries - the latter causes 202 errors, all unresolved external symbols. I've spent most days over the past week trying to get this to work and it still won't work. No matter how much I Google error codes I still can't find a fix. So I get that .lib files are compiled a certain way, how do I find out how they were compiled? I open up the .lib file and all I get is gibberish.

##### Share on other sites

It's possible there is a dump utility coming with MSVC which will show all relevant information but I'm not aware of which. Most people will just build the libraries they need themselves using their defined build environment since trying to get several libraries prebuilt with your exact desired configuration quickly turns from 'chore' to 'impossible'.

Your first step should be figuring out which library exactly is the culprit. It's unlikely to be ones which came in a .dll/.lib tuple since import libraries generally don't add such dependencies. Note that depending on the library used you still might need to ensure the .dll is compiled with compatible build settings (for example Qt relies on that, though pure C libraries generally avoid that problem by defining create/release-functions to allocate memory in their space).