Click here to Skip to main content
15,893,814 members

Redirect the object files to a different directory in ubuntu linux machine

Charmy from bangalore asked:

Open original thread
In my application folder A, there are 3 source directories B,C and D. Folder B contains 1.cpp,2.cpp,3.cpp.
FOlder C contains 4.cpp,5.cpp,6.cpp. I have written makefile for my application which is in Application folder A. I am also having the makefiles for each subdirectories as well means makefileA in folder A and makefileB in folderB.

The makefile in folder A is my main application make file.


Now When you give make from A the corresponding folders source files get complied and the .o files for B folder are generated as 1.o,2.o,3.o in B folder itself.Similarly, for C folder the .o files 4.o,5.o,6.o are generated in C folder only.
Now My requirement is the generation of .o files should be in Folder D instead of getting generated in Folders B and C.
The Folder D should have 1.o,2.0,3.o,4.o,5.o,6.o and the .o files should not be present in Folders B and C.



Solution1:
=========
Add the following line in makefile for Folder B and also in makefile for Folder C
mv *.o A/B/C/D(path where .o should be generated/redirected)

Problem with Solution1:
=======================
Solution1 works but when you do changes only in one source file,for example 2.cpp, instead of compiling only 2.cpp, it compiles all the files 1.cpp,2.cpp,3.cpp,4.cpp,5.cpp,6.cpp.This is the problem what iam facing.
Could you please suggest an efficient solution.
Tags: Ubuntu, Linux, Makefile

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900