[Media_api] Can media_api Build PortMIDI under Visual C++ 2005 for Fun and Profit?

Roger Dannenberg rbd at cs.cmu.edu
Thu Apr 12 13:47:49 PDT 2007


Peter,
    I posed this question to the list awhile ago and got no reply: Did 
Microsoft fix the bug that crashes windows if you leave a midi input 
port open? If so, and this seems to be the case based on my limited 
testing, then you don't need the pm_dll.dll -- either you're a good 
citizen and call Pm_Terminate() (recommended) or you crash or forget and 
rely on Windows to clean up. (In the past you'd have to reboot if you 
left an input port open, at least with most system/driver combinations.) 
If windows still has the bug (and maybe I just got lucky in my tests), 
then you need to call Pm_Terminate() either directly or indirectly 
through the DLL, which tries to clean up when the program exits. There's 
a compiler switch to omit the code that initializes the DLL.
    I suspect that there some interaction between the /TP, /clr, and 
extern "C" declarations. If you compile portmidi code as C++, then the 
symbols the compiler puts in the object file will be "decorated" with 
type info, but if the caller is told these are 'extern "C"' functions, 
it will be looking for undecorated symbols and the link will fail with 
the messages you posted. My guess is if you take out the extern "C" 
brackets in the header AND compile the portmidi code as C++, the link 
will work.

    -Roger



More information about the media_api mailing list