Use MINGW32 to write Win32 programs on Linux

Source: Internet
Author: User

mingw-minimalist GNU for Windows

Mingw32 is a collection of GNU project tools that contains a large number of header files, libraries, and instructions. The purpose is to provide a free tool for the production of a native program (Native Windows programs) that can be directly executed on WINODWS without a dependent helper library.

In the Debian system, you can install the DEBIANPACKAGES:MINGW32, Debianpackages:mingw32-binutils, and debianpackages:mingw32-runtime three package software.

    • Debianpackages:mingw32-minimalist GNU Win32 (Cross) compiler contains Win32 Trans-platform translator
    • Debianpackages:mingw32-binutils-minimalist GNU Win32 (Cross) binutils contains Win32 platform instruction set
    • Debianpackages:mingw32-runtime-minimalist GNU Win32 (Cross) runtime function library and target files

Debianpackages:mingw32 includes g++ (c++,cpp), GCC (cc), Gcov, Gccbug, and other required Win32 cross-platform translators, which you need to produce EXE that can be used on Microsoft Windows , DLL files, and so on. Debianpackages:mingw32-binutils are nm, strip, AR, Ranlib, Dlltool, as, LD, Windres, addr2line, size, objdump, readelf, etc. The necessary tools for producing native programs. These instructions are different from native translators, and the records are very different from other software, and are in/usr/i586-mingw32msvc/. The directive naming principle also starts with i586-mingw32msvc.

For example, a console executable is generated.

[Email protected]:~$ cat Hello.cpp
#include <iostream>
int main (int argc, char* argv[])
{
Std::cout << "Hello world\n";
return 0;
}
[Email protected]:~$ i586-mingw32msvc-g++-o hello.exe hello.cpp
[Email protected]:~$ file Hello.exe
Hello.exe:MS Windows PE 32-bit Intel 80386 console executable not relocatable

If you install wine, you can even perform it directly. Because wine is used in conjunction with Binfmt-support, your system should be aware of the. exe file and execute it in wine.

[Email protected]:~$./hello.exe
Hello World
Wine exited with a successful status

or edit a graphical user interface program that shows a message window

 [email protected]:~$ cat > Hello.cpp  
#include <windows.h>
{
MessageBox ( NULL, "Hello, world!", "", MB_OK);
return (0);
}
[email protected]:~$ i586-mingw32msvc-g++-o hello.exe hello.cpp-mwindows
[email  protected]:~$ file hello.exe
hello.exe:ms Windows PE 32-bit Intel 80386 GUI Executable not relocatable

You probably notice that the "-mwindows" parameters are added to the directive, which is used to build "Windows application" rather than "Console application" and ensure that the Windows Library is used during the connection (linking) process. In the example above we only show the "Hello World" string, which is called "Console Application", which will activate a console window. You can add "-mconsole" to edit "Console application".

Through Mingw32 's help, you can design a C + + program for "Write Once, Run Everywhere" on the Linux system, such as putty for Unix, Mac, and Windows on Linux platforms.

Taken from "Http://wiki.debian.org.tw/index.php/Mingw32"

This page has been browse 2,126 times. Last change 10:02 July 14, 2005. All Jong Yun of this site are used in the following ways: GNU Free Documentation License 1.2

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.