1

I need to write a makefile for a c++ visual-studio project running on windows. I have only 5 files that I need to compile:

main,  Board.cpp, Board.h, Node.cpp, Node.h

I want to use the "make" command in cmd and compile it all. I don't know how to write proper makefile for that, while searching I've found this Write makefile for .cpp and .hpp c++ but it is not my case.. HELP??

Community
  • 1
  • 1
mooly
  • 113
  • 1
  • 8

1 Answers1

2

The simplest would be

all:
    g++ main.cpp Board.cpp Node.cpp
FamZ
  • 461
  • 3
  • 13
  • No need to compile all header files ? and does that makefile necessarily work on all windows-OS computers? and btw, does it matter to makefile if I need to read or write from an external txt file ? – mooly Dec 14 '16 at 20:42
  • header files are never compiled and yes, even other systems like linux. it doesn't matter if you read/write external files – FamZ Dec 14 '16 at 20:43
  • Do note the tags on the question.... Visual Studio doesn't come with g++. – Cody Gray - on strike Dec 14 '16 at 20:44
  • You can replace g++ by any compiler – FamZ Dec 14 '16 at 20:46
  • and how do i know which compiler I need for my visual studio 2015 ? – mooly Dec 14 '16 at 20:47
  • 1
    Actually it doesn't really matter which compiler you are using, Visual studio has its own compiler. You can build a visual studio solution directly by replacing the g++ main.cpp Board.cpp Node.cpp with msbuild your_project.sln /Flags as described here: http://stackoverflow.com/questions/498106/how-do-i-compile-a-visual-studio-project-from-the-command-line – FamZ Dec 14 '16 at 21:05