Using the NMAKE tool to compile the connection C + + source code in a Windows environment

Source: Internet
Author: User

This article is a supplement to the previous article (http://www.cnblogs.com/LCCRNblog/p/4532643.html), so you need to look at the previous article first.

Recently, when writing code, you need to execute the generated C + + source code file by command, so you need to learn about how to use commands to compile and connect C + + original files in a Windows environment. This article is a self-groping practice to draw. As a starting point for yourself, follow up with a deep understanding of this knowledge.

1. Preparation

Write the main.cpp header.h header.cpp three source code files and put them in a folder test.

2. Writing NMAKE files

Create the Hello.mk file in the test folder and write the following script

foo:main.obj header.obj     -EHSC main.obj header.obj-o foomain.obj:main.cpp    -ehsc-c main.cppheader.obj:header.h header.cpp     -EHSC-C header.cpp Clean:    *.obj *.exe

Note that the script hollow lattice needs to be preserved, cannot be arbitrarily added and deleted. As for why, I am not very clear, follow-up slowly understand learning.

In the course of practice, I put "header.obj:header.h header.cpp" This line of Header.h removed, re-execute the script file, still able to pass, this reason I am not quite clear, because I have just touched on this knowledge, but also need to further try to further understand the principles.

Then open cmd, navigate to the test file path, first execute Vcvarsall.bat (the method is covered in the previous article), and then execute the following command

nmake/f hello.mk

The Foo.EXE executable file is generated in the Test folder.

If you execute the following command

nmake/f hello.mk Clean

All *.obj and *.exe generated in the test folder will be deleted.

Using the NMAKE tool to compile the connection C + + source code in a Windows environment

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.