开发者

Mingw32 cross compiled console application doesn't do anything on Windows XP

I've compiled a small app in Linux (Ubuntu 11.04) with Mingw32 and it runs ok in Wine, but does nothing on Wuindows (although it runs).

Configure:

./configure --host=i586-mingw32msvc --target=i586-mingw32msvc --build=i686-linux

(I've tried without --target and without --build with the same results.)

Compile:

i586-mingw32msvc-g++ -DHAVE_CONFIG_H -I. -I.. -DLOG_DOMAIN=\"tpv\" -I.. -DWINVER=0x0400 -D_WINDOWS_ -Wall -g -Wl,--subsystem,console -mconsole -mms-bitfields -g -O2 -MT tpv-excepciones.o -MD -MP -MF .deps/tpv-excepciones.Tpo -c -o tpv开发者_运维百科-excepciones.o

Link:

/bin/bash ../libtool --tag=CXX --mode=link i586-mingw32msvc-g++ -Wall -g -Wl,--subsystem,console -mconsole -mms-bitfields -g -O2 -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lmingw32 -Wl,-subsystem,console -o tpv.exe tpv-excepciones.o tpv-conf.o tpv-main.o

It generates an .exe file which is not a linux binary. It runs OK in wine, but does nothing in Windows XP.

Reading the web I've added some flags in configure time:

-Wl,--subsystem,console -mconsole -mms-bitfields

This is the program:

#include <windows.h>
#include "main.hh"


int main (int argc, char ** argv)
{
    MessageBox (0, "Joder!", "Ermmm...", MB_OK);

    //utils::conf c ("configuracion.3D");

    //std::cout << "Valor de 'no': '" << c["TEXTO_ERROR"] << "'" << std::endl;

    //std::cout << "..." << std::endl;

    return 0;
}

I've tried everything I've found on the web to no avail.

Am I missing something?


Be sure to mark the application (in the PE32 executable header, I guess) as a "GUI" application, and not console. That is, use -mwindows with mingw (and not -mconsole). Your test source compiles fine (then it works) with this simple command (on Ubuntu 15.10 at least with deb package gcc-mingw-w64-i686 installed): i686-w64-mingw32-gcc -o test.exe test.c -mwindows.

I am far from being a Windows expert (not even a user too much ...), but as far as I know, Windows has a strict view that an application is console or GUI based, you can use the -mwindows switch to set this as "GUI application". I think, using a simple dialog box you've tried needs the application to be GUI based, and that could be the problem, that you haven't done that. A simple way to check your .exe:

lgb@antares:~$ file test.exe
test.exe: PE32 executable (GUI) Intel 80386, for MS Windows

Please note however, that a GUI application does not have console, so then you can't just printf() or other stdio functions to write to the console, because ... you haven't got a console :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜