GNOME Bugzilla – Bug 682071
Fix Visual C++ build when using the SDL winsys
Last modified: 2012-09-19 07:38:40 UTC
Hi, This will apply to both the cogl-1.12 and master branches. When I am building programs using cogl with the SDL winsys, I found that the re-factoring in the SDL winsys code that was done some time ago introduced a direct dependency on SDL.lib (and SDLmain.lib) on all programs using SDL, at least on Visual C++ builds, as we are including SDL.h for the SDL_Event type. This would cause linker errors looking for _main() to appear when such programs are being linked, which could be puzzling as the linker was actually trying to look for the specialized main() implementation that is given in SDLmain.lib. As it would not be exactly clear whether cogl is using the SDL winsys to the app developer at build time, I thought it might be a good idea to add the following into cogl-sdl.h when Visual C++ is used to build/use cogl with the SDL winsys: #pragma comment (lib, "SDL.lib") #pragma comment (lib, "SDLmain.lib") so that SDL.lib and SDLmain.lib will be linked in at the linking stage. With blessings, thank you!
Created attachment 221546 [details] [review] cogl/cogl-sdl.h: Link to SDL on Visual C++ This is the patch to remedy the issue.
OK, this all sounds a bit mad, but yeah the problem sounds real and the patch looks like a plausible fix so I'm happy if you want to push this :-) In addition to this it sounds like we should also look at making the cogl-sdl.h be standalone so that applications have to explicitly include it so they can avoid redefining the name of their main function if they don't want to use SDL but Cogl happens to have been built with SDL support. This is a separate issue though.
Hi, Patch pushed as: 2921d2a4 in master b743d95e in cogl-1.12 Sorry for the delay in pushing the patches, as I was away for a few days. Thank you!