|
From: Earnie B. <ear...@ya...> - 2003-05-22 10:54:44
|
Paul G. wrote:
>
>>Hello
>>
>>If I build a Win32 app with flag -mwindows, I wonder if there is a way
>>to enable console output from printf, to the console(sh) that I start
>>the program(started from commandline in msys sh)?
>
>
> Yes.
>
Ok, I was wrong. However,
> It is a fairly straightforward operation using C/C++:
>
> $ g++ -v
> Reading specs from d:/msys/1.0/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/specs
> Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --
> prefix=/mingw --enable-threads --disable-nls --enable-languages=c++,f77,objc --disable-win32-registry --disable-
> shared --enable-sjlj-exceptions
> Thread model: win32
> gcc version 3.2.3 (mingw special 20030504-1)
>
> Source follows:
>
> #include <windows.h>
> #include <iostream>
>
> int WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
> {
>
> MessageBox (NULL, "Hello, Windows!", "Hello", MB_OK);
> printf("hello world\n");
s/printf("hello world\n");/std::cout << "Hello, world!" << std::endl;/
> return 0;
> }
>
> end of source
>
> compile with:
>
> g++ hello.cpp -ohello.exe -mwindows -mconsole
>
Then ``g++ hello.cpp -o hello.exe'' works as well.
> Automatic output to both a window (message box) and to the Msys sh/console.
>
> Allows you to immediately output to the console (under Msys shell) and can be extended to include a full-blown
> Window as needed. What is critical is that the -mconsole switch is included when the app is compiled (in addition to
> the -mwindows switch).
>
So, how critical are -mwindows and -mconsole? Since gdi32 isn't used in
your example, is it really a windows program?
Earnie.
|