Compiling under mingw

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

samsaga2
Posts: 1
Joined: Fri Feb 20, 2015 2:38 pm

Compiling under mingw

Post by samsaga2 »

When I try to compile scummvm under mingw I've got this error message:
$ make
C++ backends/platform/sdl/sdl.o
C++ backends/platform/sdl/win32/win32-main.o
backends/platform/sdl/win32/win32-main.cpp: In function ‘int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)’:
backends/platform/sdl/win32/win32-main.cpp:44:14: error: ‘__argc’ was not declared in this scope
return main(__argc, __argv);
^
backends/platform/sdl/win32/win32-main.cpp:44:22: error: ‘__argv’ was not declared in this scope
return main(__argc, __argv);
^
backends/platform/sdl/win32/win32-main.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
Makefile.common:103: recipe for target 'backends/platform/sdl/win32/win32-main.o' failed
make: *** [backends/platform/sdl/win32/win32-main.o] Error 1
Maybe there are mixed code from Visual C++ to g++?
User avatar
LordHoto
ScummVM Developer
Posts: 1029
Joined: Sun Oct 30, 2005 3:58 pm
Location: Germany

Re: Compiling under mingw

Post by LordHoto »

samsaga2 wrote:When I try to compile scummvm under mingw I've got this error message:
$ make
C++ backends/platform/sdl/sdl.o
C++ backends/platform/sdl/win32/win32-main.o
backends/platform/sdl/win32/win32-main.cpp: In function ‘int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)’:
backends/platform/sdl/win32/win32-main.cpp:44:14: error: ‘__argc’ was not declared in this scope
return main(__argc, __argv);
^
backends/platform/sdl/win32/win32-main.cpp:44:22: error: ‘__argv’ was not declared in this scope
return main(__argc, __argv);
^
backends/platform/sdl/win32/win32-main.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
Makefile.common:103: recipe for target 'backends/platform/sdl/win32/win32-main.o' failed
make: *** [backends/platform/sdl/win32/win32-main.o] Error 1
Maybe there are mixed code from Visual C++ to g++?
That might be an issue with your MinGW setup. We use MinGW and MinGW64 on our buildbot to build ScummVM and it works fine there.

It would be helpful to know some more details like: What version of MinGW are you using? Where did you get it from? Did you use any special CXXFLAGS when configuring ScummVM? etc.
Lostech
Posts: 157
Joined: Fri May 04, 2007 8:42 am
Contact:

Post by Lostech »

I didn´t try to compile ScummVM under MSYS/MINGW for a long time but I remember that these problems occur under Windows with the Windows MINGW not with the LINUX MINGW for cross compiling. I think Cygwin did show also the same errors.
digitall
ScummVM Developer
Posts: 1075
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall »

__argc and __argv are global variables provided in stdlib.h. See: https://stackoverflow.com/questions/179 ... v-in-mingw

I wonder if we should parse the lpCmdLine string explicitly instead as in: http://www.cmake.org/pipermail/cmake/20 ... 05172.html ?
User avatar
clone2727
Retired
Posts: 1611
Joined: Fri Jun 09, 2006 8:23 pm
Location: NJ, USA

Post by clone2727 »

digitall wrote:I wonder if we should parse the lpCmdLine string explicitly instead as in: http://www.cmake.org/pipermail/cmake/20 ... 05172.html ?
We should not be parsing the command line ourselves -- that's why argc and argv exist in the first place.

Before we jump to any sort of guess or conclusion, we need to hear back from samsaga2 how he/she set up MinGW.
digitall
ScummVM Developer
Posts: 1075
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall »

SIGH. Yes, but they don't exist on WINDOWS. The MinGW compiler environment provides them as __argc and __argv... or should.

I did some checking and ludde's other project, OpenTTD actually does the parsing to create argc and argv for Windows in the codebase as well, rather than relying on MinGW to provide this:
http://hg.openttd.org/openttd/trunk.hg/ ... 2.cpp#l422
User avatar
clone2727
Retired
Posts: 1611
Joined: Fri Jun 09, 2006 8:23 pm
Location: NJ, USA

Post by clone2727 »

Of course it provides it. How else would everyone else be compiling on Windows? Do you really think it's not working for anyone right now? Hell, I just helped waltervn set it up last week.

It's ridiculous to jump to this conclusion without any details on what he/she has set up.
digitall
ScummVM Developer
Posts: 1075
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall »

I'm sorry... What conclusion do you feel I am jumping to?
User avatar
clone2727
Retired
Posts: 1611
Joined: Fri Jun 09, 2006 8:23 pm
Location: NJ, USA

Post by clone2727 »

That we need to parse lpCmdLine or that __argc and __argv are not normally available on MinGW for Windows. Instead of trying to ascertain the exact problem samsaga2 is having, you've now posted two links that are about that "issue". Let sansaga2 respond to LordHoto's post.
digitall
ScummVM Developer
Posts: 1075
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall »

Firstly, I am not preventing samsaga2 from providing a response to Lordhoto's query. In fact, I totally agree with his inquiry i.e. "It would be helpful to know some more details like: What version of MinGW are you using? Where did you get it from? Did you use any special CXXFLAGS when configuring ScummVM? etc."

However, it has been 5 days since he posted that and samsaga2 has not responded. It would probably be useful to provide some specific instructions for him to run to get that information as MinGW for Windows doesn't have a clear "version" for the entire package and via mingw-get is auto-updating so hard to get a good answer... so I don't think he is going to respond.
digitall
ScummVM Developer
Posts: 1075
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall »

Secondly, I never stated that I do not believe MinGW for Windows is not providing these, but the provided error messages from the compiler say exactly that:
<snip>
C++ backends/platform/sdl/win32/win32-main.o
backends/platform/sdl/win32/win32-main.cpp: In function ‘int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)’:
backends/platform/sdl/win32/win32-main.cpp:44:14: error: ‘__argc’ was not declared in this scope
return main(__argc, __argv);
^
backends/platform/sdl/win32/win32-main.cpp:44:22: error: ‘__argv’ was not declared in this scope
return main(__argc, __argv);
</snip>

I suggested that maybe since the code was already Win32 specific and has the command line string as LPSTR, we could avoid using the MinGW provided __argc and __argv and do the command line string parsing in-tree as per OpenTTD to avoid this in future.
digitall
ScummVM Developer
Posts: 1075
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall »

Thirdly, I have just updated MinGW for Windows on my WinXP 32-bit box using "mingw-get update" followed by "mingw-get upgrade" to the latest version to see if this fails.

This is from http://www.mingw.org/ originally and is using GCC 4.8.1 currently.

I have then tried a normal "./configure && make clean && make" build of ScummVM at the command line and this compiles backends/platform/sdl/win32/win32-main.o with no problems.

I threfore concur that this appears to just be broken for samsaga's setup and he should check with the MinGW configuration and compilation instructions here:
http://wiki.scummvm.org/index.php/Compi ... mmVM/MinGW
User avatar
LordHoto
ScummVM Developer
Posts: 1029
Joined: Sun Oct 30, 2005 3:58 pm
Location: Germany

Post by LordHoto »

digitall wrote:I suggested that maybe since the code was already Win32 specific and has the command line string as LPSTR, we could avoid using the MinGW provided __argc and __argv and do the command line string parsing in-tree as per OpenTTD to avoid this in future.
Funnily enough, __argc and __argv we are using seem to also be Win32 specific. See here.

That probably also explains why Cygwin shows similar errors. But I am pretty sure we do not support Cygwin anymore anyway. So, that's really not surprising.
digitall
ScummVM Developer
Posts: 1075
Joined: Thu Aug 02, 2012 1:40 pm

Post by digitall »

LordHoto: Thanks for that as I hadn't spotted that. Doing the argc/argv parsing in our code as per OpenTTD by parsing LPSTR cmdline was purely a suggestion, but I do concede that if samsaga2's MinGW setup is broken in this way, it is likely broken in other ways, so he should fix that.
Lostech
Posts: 157
Joined: Fri May 04, 2007 8:42 am
Contact:

Post by Lostech »

@LordHoto:
I gave Cygwin a try because it normally has less problems as MinGW. So this was JFI.

@digitall:
Did you use MSYS/MinGW?
Post Reply