Search code examples
c++cdtray

Getting error while trying to open CD Tray in C++


I cannot seem to be able to open the CD Tray. It pops me some error with 'extern C' what does extern mean too?

Thanks! Here's the image! Error in C++ opening CD Tray


Solution

  • "extern C" isn't really relevant here. The actual problem is the "unresolved external" errors on your call to mciSendString(). It means the compiler knows that the function exists (because the declaration has presumably been included in a header). However, it doesn't know where the implementation of that function is.

    That usually means you haven't linked to a required external library. Microsoft's documentation indicates that you need the Winnmm.lib library in order to use mciSendString(). You need to specify that library in your project settings, which is usually under something like "Linker -> Input -> Additional Dependencies" in Visual Studio.