After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 682071 - Fix Visual C++ build when using the SDL winsys
Fix Visual C++ build when using the SDL winsys
Status: RESOLVED FIXED
Product: cogl
Classification: Platform
Component: Win32
1.11.x
Other Windows
: Normal normal
: ---
Assigned To: Cogl maintainer(s)
Cogl maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-08-17 03:19 UTC by Fan, Chun-wei
Modified: 2012-09-19 07:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
cogl/cogl-sdl.h: Link to SDL on Visual C++ (1.46 KB, patch)
2012-08-17 03:31 UTC, Fan, Chun-wei
none Details | Review

Description Fan, Chun-wei 2012-08-17 03:19:34 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!
Comment 1 Fan, Chun-wei 2012-08-17 03:31:08 UTC
Created attachment 221546 [details] [review]
cogl/cogl-sdl.h: Link to SDL on Visual C++

This is the patch to remedy the issue.
Comment 2 Robert Bragg 2012-09-12 14:08:28 UTC
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.
Comment 3 Fan, Chun-wei 2012-09-19 07:38:40 UTC
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!