0

I have been trying to read around about this, but I can't figure out how to fix it.

I have the following makefile and I would like to put objects in to libs/ subfolder and executable to build/ folder...but no matter what I have tried, I can't figure out how to tell make such ruling.

cxx = g++
flags = -mwindows
sources = $(wildcard *.cpp)
objects = $(sources:.cpp=.o)
target = engine

all: $(sources) $(target)

$(target): $(objects)
    $(cxx) $(objects) -o $@

.cpp.o:
    $(cxx) -std=c++11 -c $< -o $@
  • 1
    Possible duplicate of [Makefiles - Compile all .cpp files in src/ to .o's in obj/, then link to binary in /](http://stackoverflow.com/questions/2908057/makefiles-compile-all-cpp-files-in-src-to-os-in-obj-then-link-to-binary) – user657267 Sep 22 '16 at 12:59
  • There are dozens of examples of how to do this, it's probably the most frequently asked makefile question. – user657267 Sep 22 '16 at 12:59

0 Answers0