I am attempting to use a MEX routine to launch a lightweight OpenGL-based window, driven with SDL. The window is successfully launched when compiled as a standalone EXE in Visual Studio. When I call the same method from mexFunction(), however, I run into everyone's favorite linking error:
error LNK2019: unresolved external symbol SDL_GL_SetAttribute referenced...error LNK2019: unresolved external symbol SDL_SetVideoMode referenced...error LNK2019: unresolved external symbol SDL_Init referenced...[...]
However, SDL.lib and SDLmain.lib are indeed on the linker's path. I chose to place them in …/Program Files/Microsoft SDKs/Windows/…, and removing or renaming them causes a 'cannot open input file' error–LNK1181–so I know they are in scope.
I have tried to address this issue by creating my own MEX options file from the default mexopts.bat, repeatedly adjusting linker options to converge as close as possible to the Visual Studio command line link options. However, I continue to receive LNK2019 errors.
I have also considered that this be the result of MATLAB trying to compile a 64-bit MEX routine against 32-bit static libraries. However, it only complains about symbols from SDL.lib, and not OpenGl32.lib. Even if this was the case, I should be seeing a LNK2001 error instead.
I'm a little bit out of my Comfort Zone of Absolute Certainty in this case, and seem to have exhausted my creative problem-solving abilities for the time being. The last option I can think of is to completely recompile the SDL static libraries, but I don't want to go through the pain of doing so if it's not going to give me anything different than the libraries I already have. Any suggestions?
[EDIT: Removed superfluous sentence. 8/4/2011 @ 11:37PM]
Best Answer