Opened 17 years ago

Closed 16 years ago

Last modified 6 years ago

#3412 closed defect

TOOLS: MinGW tools building broken

Reported by: lordhoto Owned by: Kirben
Priority: normal Component: Tools
Version: Keywords:
Cc: Game:


Since the tools (create_kyradat/create_lure) are included in the default build, ScummVM doesn't build fine anymore on Win32 with MinGW.

Error message: g++ tools/create_kyradat/create_kyradat.o tools/create_kyradat/pak.o tools/create_kyradat/md5.o tools/create_kyradat/util.o -o tools/create_kyradat/create_kyradat.exe X:/MSYS/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16' collect2: ld returned 1 exit status make: *** [tools/create_kyradat/create_kyradat.exe] Error 1

scummvm.exe is built before that, so itself it's working. Still our default build rule is broken.

Ticket imported from: #1800764. Ticket imported from: bugs/3412.

Change History (19)

comment:1 by Kirben, 17 years ago

The problem is due to SDL redefining main under MinGW, the SDL includes shouldn't be included when compiling these non-SDL tools.

comment:2 by lordhoto, 17 years ago

Yeah itt seems like $INCLUDES includes "-Dmain=SDL_main" which of course is wrong for the tools. Anyway the tools shouldn't contain any backend specific cpp/cxx/ld flags, so I guess this is there the problem is.

comment:3 by fingolfin, 17 years ago

Maybe Kirben has some insights on this.

If I understand this correctly, on Windows one needs WinMain instead of main ? Would an simple #define be enough? Or do we need to use the SDL libs to get a "good" WinMain? Or what... ?

comment:4 by fingolfin, 17 years ago

Owner: set to Kirben

comment:5 by lordhoto, 17 years ago

MinGW is fine with 'main' too, but if no 'main' symbol is found in the objects it thinks of an Win32 app (instead of an 'console app') and searches for WinMain, which is a bit different from a normal main ( Now the problem is that the SDL cppflags include '-Dmain=SDL_main' which makes no 'main' symbol appear while linking and thus it looks for WinMain, which is also not present.

What has to be done about is that the SDL specific cppflags shall not be passed while building the tools (the SDL ldflags aren't used while linking the tools too, so I guess it would make sense to exclude the SDL cppflags anyway).

comment:6 by SF/icall, 17 years ago

you should add sdlmain.lib(get it from SDL) to scummvm's link library.

comment:7 by fingolfin, 17 years ago

Summary: MinGW: tools building brokenTOOLS: MinGW tools building broken

comment:8 by fingolfin, 17 years ago

No, adding sdlmain.lib would not be the correct solution. LordHoto already explained the proper way to fix this.

However, with the current build system it is not completely straightforward to get rid of the SDL cppflags. Instead, how about (for now) just adding #ifdef main #undef main #endif

to the top of the file?

comment:9 by lordhoto, 17 years ago

Yeah that works fine, I will add it for now with a comment linking to this tracker item.

comment:10 by sev-, 16 years ago

Raising priority. This is a release-critical bug.

comment:11 by sev-, 16 years ago

Priority: normalblocker

comment:12 by Kirben, 16 years ago

Why release-critical bug? the current workaround in ScummVM SVN works fine.

comment:13 by sev-, 16 years ago

Lowering the priority. I just have no ability to check it and thus had an impression that the issue still persists.

comment:14 by sev-, 16 years ago

Priority: blockernormal

comment:15 by fingolfin, 16 years ago

Actually, is there any reason to keep this bug open? If so: What remains to be done?

comment:16 by fingolfin, 16 years ago

Status: newpending

comment:17 by lordhoto, 16 years ago

Status: pendingclosed

comment:18 by lordhoto, 16 years ago

We still have just a workaround implemented, so the real problem is not fixed yet. But since we do not build tools by default, we can just close this.

comment:19 by digitall, 6 years ago

Component: Tools
Note: See TracTickets for help on using tickets.