help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem when source and object files are in different paths


From: David Aldrich
Subject: Problem when source and object files are in different paths
Date: Wed, 28 Sep 2016 10:56:18 +0000

Hi

My project looks like:

├── build
│   |── makefile
|
└── src
    ├── subsys1
    │   ├── includes
    │   └── src_1.cpp
    └── subsys2
        ├── includes
        └── src_2.cpp

I want the object files and executable to be stored in the build directory.

My makefile has:

OBJDIR = _gnuRelease

CPP_FILES = ../src/subsys1/src_1.cpp ../src/subsys1/src_2.cpp

OBJ_FILES_TMP = $(patsubst %.cpp,%.o,$(CPP_FILES))
OBJ_FILES = $(addprefix $(OBJDIR)/,$(notdir $(OBJ_FILES_TMP)))

$(APP) : $(OBJ_FILES)
        $(LINKER) $(CXXFLAGS) $^ -o $@ 

%.o: %.cpp
        $(CXX) $(CXXFLAGS) $(INC_SWITCHES) -c $< -o $@

Best regards

David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]