Msys + mingw is handy!

Source: Internet
Author: User
1 origin

At ordinary times, in some C ++ groups, I saw many universities studying C ++/mfc with great efforts and seeing that when programming languages were all over the world, c/C ++ is very attractive. It is estimated that many beginners use visual stdio development tools in windows. Through this article, you can compile other C ++ tools to integrate the development capabilities of Linux and Windows C ++.

I have been engaged in C/C ++ development in Windows/Linux over the years, and made a review and summary of the development tools I have used at ordinary times, this section describes the simple use of msys + mingw tools and the Cross-Compiling of Windows programs in Linux. The star msys + mingw mentioned in this Article will be introduced below

2. How can I view the Append content at the end of the real-time log file in the window?

To develop a project, you must have a log file to output some log information. In this way, developers can search for the bugs Through log.

Currently, all development languages provide ready-to-use classes to output logs.

So how can I view this incremental real-time log on the window platform?

It is too troublesome to use the text editor world to open it, and it is not convenient to view the appended content at the end.

What should we do?

A friend who has solved Linux/Unix will think that if there is a tail command, a tail-F/var/log/a. log can view the real-time log increment.

So the stars are on the stage.

3. Practitioners advocating the GNU spirit on the msys + mingw window platform.

Let's take a look at Baidu encyclopedia is how to introduce http://baike.baidu.com/view/371287.htm? Fr = Aladdin

Minimal GNU (POSIX) System on Windows is a small GNU environment, including basic bash and make. It is the best GNU environment in windows. (If you are tired of cygwin's snail like shell environment, try rxvt in msys)

 

Mingw: Minimalist GNU for Windows. It is a collection of header files and function libraries that allow people to use GCC (GNU Compiler C) to generate Win32 programs without a third-party dynamic link library. Mingw consists of GNU binary utilities, GCC, and GDB. It also includes necessary libraries, such as libc (C Runtime) and API libraries dedicated for Win32 environments. If you want to learn programming in a Linux environment and do not want to install Linux, you can install mingw.

With msys + mingw, we can learn GCC programming in the window, consistent with the Linux program to the window.

Encyclopedia also mentioned the disadvantages of "cousin cygwin" of msys + mingw. When msys + mingw is not popular yet, everyone uses cygwin. I can only sigh that "Being blue is better than being blue". cygwin is no longer the "sweet" of the year"

4. Install msys + mingw with one click.

Go to the mingw website http://www.mingw.org/and click Download on the left navigation bar to go to sourceforge.net to downloadMingw-get-setup.exe (86.5 KB)

Choose msys-base, mingw32-base, mingw-developer-Toolkit, mingw-gcc-G ++ package for Installation

The default installation path is c: \ mingw. Enter c: \ mingw \ msys \ 1.0 to create a desktop shortcut for msys.

Click the msys icon on the desktop to start the msys journey.

 

5. image details: tail detects the Append content at the end of the file.

Access disk C in msys using/C/, disk D/, and other disks.

The following example shows how to use the tail command to check the incremental content at the end of the D:/test. Log File and append the content to the file using echo.

It is indeed what everyone expects !!!

In the future, we will view the program text log in real time on the window platform ..

6. Add the left-hand wget "image website does not ask for help" to msys"

You can download the wget program in Baidu, which is widely used on the Linux platform.

This section describes how to compile in msys. On the window platform, you can mirror a website without asking for third-party software.

Download wget-1.15.tar.gz first. Copy it to c: \ mingw \ msys \ 1.0 \ home.


In this way, just like compiling a program in Linux, the program will be compiled soon. The following figure shows how wget is used to image the website.

CD; wget.exe-r-p-NP-K http://www.xiulian.com/XMZHF/xmzf-index.htm
-R indicates that recursive download will download all links, but note that you should not use this parameter separately, because if the website you want to download also has a link to another website, wget will also download things from other websites. Therefore, the-NP parameter must be added, indicating that the link of other websites will not be downloaded.
-NP indicates that the link of other sites is not downloaded.
-K indicates modifying the link in the downloaded webpage to a local link.
-P: Get all the elements required to display the webpage, such as slice or something.
-E or -- HTML-Extension: Set the suffix of the urlfile to ". html"

The download process logs are shown in the following figure: www.xiulian.com.

Do you already feel the greatness of open source? In the future, wget will be done by mirroring a web page, and you will no longer need the paid software or the old advertisement software.

With msys + mingw, a lot of software in Linux can be compiled to tell your window platform to plug in "Wings".

 

However, you may feel that the software compiled with msys is slow, not as fast as compiling software in Linux!

Next we will introduce the last Gameplay in this article.

7 "exclusive gameplay"-mingw-w64 compiling Win32/win64 software in Linux

First, we will introduce the environment. I am using the debian7.3 system, which is running in the virtualbox virtual machine.

Next introduces the mingw-w64 has 2 versions of Compiler

G ++-mingw-w64-i686-gnu c ++ compiler for MinGW-w64 targeting Win32 -- generate a 32-bit program
G ++-mingw-w64-x86-64-gnu c ++ compiler for MinGW-w64 targeting win64 -- generate a 64-bit program

In Debian, I chose to generate the G ++-mingw-w64-i686 for a 32-bit program, which is easy to install using the apt-GET command.

Apt-Get install binutils-mingw-w64-i686 g ++-mingw-w64-i686 mingw-w64-i686-dev mingw-w64-tools

The code for creating a helloword. cpp file is as follows:

# Include <cstdio>
# Include <cstdlib>
# Include <iostream>

Int main (INT argc, char * argv [])
{
STD: cout <"compile Hello world.exe by Linux and i686-w64-mingw32-g ++ \ n ";
System ("pause ");
Return 0;
}

Compile the program

I686-w64-mingw32-g ++ hellword. cpp-O helloword.exe

Run helloword.exe compiled by linuxin the window

True. Personality guarantee ..

Some spectators feel that this is too simple and enjoyable!

8. Kill: Use mingw in Linux to cross-compile wget running on the window Platform

Download the wget source code and decompress it in the same six sections. Run the following commands to compile wget.exe.

Export connection = i686-w64-mingw32-gcc
Export ranlib = i686-w64-mingw32-ranlib
Export libs =-lpthread
./Configure -- Host = mingw32 -- without-SSL -- disable-ipv6

Make

Download wget.exe to the window desktop and run it,

9 Summary

The previous section describes some simple usage of mingw + msys. If you are interested in mingw, you can play with it. In fact, the C ++/C developer's eyes in the window are highlighted .. Some epiphany.

In the popular media player VLC community, mingw in Linux is used to cross-compile the VLC running in the window, which is one of the reasons why people prefer mingw more and more.

If you have any questions, please contact me here to step on more posts!

 

                       

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.