[英]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). 我使用Mingw32在Linux(Ubuntu 11.04)中编译了一个小应用程序,它在Wine中运行正常,但在Wuindows上没有任何作用(尽管它运行)。
Configure: 配置:
./configure --host=i586-mingw32msvc --target=i586-mingw32msvc --build=i686-linux
./configure --host = i586-mingw32msvc --target = i586-mingw32msvc --build = i686-linux
(I've tried without --target
and without --build
with the same results.) (我尝试过没有
--target
,没有--build
,结果相同。)
Compile: 编译:
i586-mingw32msvc-g++ -DHAVE_CONFIG_H -I.
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
-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
/ 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 -lctctl32 -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. 它生成一个不是Linux二进制文件的.exe文件。 It runs OK in wine, but does nothing in Windows XP.
它在葡萄酒中运行正常,但在Windows XP中无效。
Reading the web I've added some flags in configure time: 阅读网页我在配置时添加了一些标志:
-Wl,--subsystem,console -mconsole -mms-bitfields
-Wl, - 子系统,控制台-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. 请务必将应用程序(在PE32可执行文件头中,我猜)标记为“GUI”应用程序,而不是控制台。 That is, use
-mwindows
with mingw (and not -mconsole
). 也就是说,使用
-mwindows
和mingw(而不是-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
. 使用这个简单的命令(在Ubuntu 15.10上至少安装了deb软件包
gcc-mingw-w64-i686
),你的测试源编译得很好(然后就可以了): 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". 我远不是一个Windows专家(甚至不是一个用户太多......),但据我所知,Windows有一个严格的观点,即应用程序是基于控制台或GUI,你可以使用
-mwindows
开关来设置这是“GUI应用程序”。 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. 我认为,使用一个简单的对话框,你已经尝试过需要基于GUI的应用程序,这可能是问题所在,你还没有这样做。 A simple way to check your .exe:
检查.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 :) 但请注意,GUI应用程序没有控制台,因此您不能只是
printf()
或其他stdio
函数写入控制台,因为...您还没有控制台:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.