Unresolved external symbol: SDL/OpenGL libraries linked from MEX using Visual Studio
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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]
0 Kommentare
Akzeptierte Antwort
Kaustubha Govind
am 4 Aug. 2011
It seems to me like the issue really is because you are attempting to link a 32-bit static library against a 64-bit MEX function. Apparently, OpenGL32 is a 64-bit library on 64-bit Windows machines. From this page:
"If you are running a 64 bit version of Windows, you might be wondering if there is a OpenGL64.dll file. The answer is no, there isn't. On all versions of Windows, Windows\System32 contains all the 64 bit DLLs. It contains the OpenGL32.dll which is actually a 64 bit dll."
This is why you don't getting linking errors against OpenGL32.lib.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!