Answer the question
In order to leave comments, you need to log in
How to build a program so that the object files are not in the source directory?
Hello, there is a hello.c file in the /hello directory, I created another /hello/arch in this directory... I put the following makefile in it:
all: hpp
hpp : ../hello1.o
gcc ../hello1.o -o hpp
../hello1.o : ../hello.c
gcc -c ../hello.c
Answer the question
In order to leave comments, you need to log in
Replacing "../hello1.o" with "hello1.o"
UPD: The one to the left of the colon is just a label. It has nothing to do with filenames. With the same success, you can write like this:
all: hpp
hpp: compile
gcc hello.o -o hpp
compile: ../hello.c
gcc -c ../hello.c
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question