简体   繁体   中英

How can I create and use a Makefile on Windows?

I know how to write Makefiles for Linux, and was hoping it would be similar in Windows. However, from what I've seen on the internet, it is quite difficult.

If I have one file main.cpp , what would be the simplest form of a Makefile? Also, what would be the command to make Makefile ?

Thanks!

In brief...

$ ls && cat main.cpp && cat Makefile && make && ./main
Makefile main.cpp
/* main.cpp */
#include <iostream>
int main(int, char **) {
  std::cout << __func__ << "@" << __FILE__ << ":" << __LINE__ << std::endl;
  return EXIT_SUCCESS;
}
# Makefile
all: main
clean: ; rm -f main
g++     main.cpp   -o main
main@main.cpp:4
$ 

That's as bare-bones as I can make it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM