Configure makefile in msys + mingw

Source: Internet
Author: User

Before reading this article, please confirm that you understand

Http://blog.csdn.net/dcmilan/article/details/7983697

Http://blog.csdn.net/dcmilan/article/details/7986961

 

1. Install msys

Msys can be downloaded from the mingw official website. I will use version 1.0 here.

After installation, the GNU make file is displayed in the C: \ msys \ 1.0 \ bin folder.

When using make in cmd, You need to display the call full path C: \ msys \ 1.0 \ bin \ Make

 

2. Prepare CPP and makefile
// hello.cpp#include <iostream>int main( ){   std::cout << "Hello, World!\n";} 

 

// Makefile (this line should not appear in the Code. The command line part of makefile must start with a tab rather than a space) # This is the default target, which will be built when # You invoke make. phony: allall: hello # This rule tells make how to build hello From hello. cpphello: Hello. cppg ++-O hello. CPP # This rule tells make to copy hello to the binaries subdirectory, # creating it if necessary. phony: installinstall: C:/msys/1.0/bin/mkdir-P binariesc:/msys/1.0/bin/CP Hello binaries # This rule tells make to delete hello and hello. o. phony: cleanclean: C:/msys/1.0/bin/Rm-F hello

 

Create a folder "hello", and then create the corresponding file "Hello. cpp" and "makefile" in the "hello" folder.

 

3. Execute the make command

Switch the directory to hello in the CMD environment.

Run the C:/msys/1.0/bin/make Hello command.

 

Generate hello.exe

 

Then run C:/msys/1.0/bin/make install.

 

Create a binariesfolder and copy hello.exe to it

 

Note: The makefile here is the complete file name. Make command

 

The file is automatically located and the corresponding segment of the file is operated.

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.