make: *** No rule to make target 'agenda.cpp', needed by 'agenda'. Stop. #Making Makefile
I have a C++ project with this file structure:
include files:
src files:
In order to compile it and run I'm trying to create simple Makefile. After going through some tutorials, that what i got so far:
vpath %.hpp include
vpath %.cpp src
agenda: agenda.cpp User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o
g++ agenda.cpp User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o -o agenda
User.o:User.hpp User.cpp
g++ -c -std=c++11 User.cpp
Date.o:Date.hpp Date.cpp
g++ -c -std=c++11 Date.cpp
Meeting.o:Meeting.hpp Meeting.cpp
g++ -c -std=c++11 Meeting.cpp
Storage.o:Storage.hpp Storage.cpp
g++ -c -std=c++11 Storage.cpp
AgendaService.o:AgendaService.hpp AgendaService.cpp
g++ -c -std=c++11 AgendaService.cpp
AgendaUI.o:AgendaUI.hpp AgendaUI.cpp
g++ -c -std=c++11 AgendaUI.cpp
clean:
rm User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o
And by the way, the main function here is agenda.cpp
file. So by executing the make
command I'm getting this error:
make: *** No rule to make target 'agenda.cpp', needed by 'agenda'. Stop.
My guess is it can't find the path to agenda.cpp otherwise it wouldn't ask to make a rule. Anyway not sure, hope someone could explain.
EDIT.0:
I have edited makefile by adding vpath, but still get the error(new):
g++ -c -std=c++11 User.cpp
g++: error: User.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
make: *** [makefile:9: User.o] Error 1
Seems like this time it found agenda.cpp
and User.hpp
but can't find User.cpp
. Really would appreciate any clue, was working on it for a long time.
EDIT.1:
#VPATH = src:include
#CPPFLAGS = -I include
#vpath %.hpp include
#vpath %.cpp src
bin/agenda: build/User.o build/Date.o build/Meeting.o build/Storage.o build/AgendaService.o build/AgendaUI.o
@mkdir -p bin
g++ -std=c++11 -w -I./include $^ -o $@
build/%.o: src/%.cpp
@mkdir -p build
g++ -std=c++11 -w -I./include -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
After spending some time on my Makefile, that is the final answer,it compiles fine all *.cpp files, stores obj file in build folder,no problem,except agenda.cpp(main-file),i didn't get my executable file. But got this error:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [makefile:8: bin/agenda] Error 1
How Could i fix this?
c++ makefile
|
show 4 more comments
I have a C++ project with this file structure:
include files:
src files:
In order to compile it and run I'm trying to create simple Makefile. After going through some tutorials, that what i got so far:
vpath %.hpp include
vpath %.cpp src
agenda: agenda.cpp User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o
g++ agenda.cpp User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o -o agenda
User.o:User.hpp User.cpp
g++ -c -std=c++11 User.cpp
Date.o:Date.hpp Date.cpp
g++ -c -std=c++11 Date.cpp
Meeting.o:Meeting.hpp Meeting.cpp
g++ -c -std=c++11 Meeting.cpp
Storage.o:Storage.hpp Storage.cpp
g++ -c -std=c++11 Storage.cpp
AgendaService.o:AgendaService.hpp AgendaService.cpp
g++ -c -std=c++11 AgendaService.cpp
AgendaUI.o:AgendaUI.hpp AgendaUI.cpp
g++ -c -std=c++11 AgendaUI.cpp
clean:
rm User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o
And by the way, the main function here is agenda.cpp
file. So by executing the make
command I'm getting this error:
make: *** No rule to make target 'agenda.cpp', needed by 'agenda'. Stop.
My guess is it can't find the path to agenda.cpp otherwise it wouldn't ask to make a rule. Anyway not sure, hope someone could explain.
EDIT.0:
I have edited makefile by adding vpath, but still get the error(new):
g++ -c -std=c++11 User.cpp
g++: error: User.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
make: *** [makefile:9: User.o] Error 1
Seems like this time it found agenda.cpp
and User.hpp
but can't find User.cpp
. Really would appreciate any clue, was working on it for a long time.
EDIT.1:
#VPATH = src:include
#CPPFLAGS = -I include
#vpath %.hpp include
#vpath %.cpp src
bin/agenda: build/User.o build/Date.o build/Meeting.o build/Storage.o build/AgendaService.o build/AgendaUI.o
@mkdir -p bin
g++ -std=c++11 -w -I./include $^ -o $@
build/%.o: src/%.cpp
@mkdir -p build
g++ -std=c++11 -w -I./include -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
After spending some time on my Makefile, that is the final answer,it compiles fine all *.cpp files, stores obj file in build folder,no problem,except agenda.cpp(main-file),i didn't get my executable file. But got this error:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [makefile:8: bin/agenda] Error 1
How Could i fix this?
c++ makefile
2
Remember that paths are relative. There is noagenda.cpp
file in the same directory asmakefile
. There is on the other hand asrc/agenda.cpp
file. The same problem with all your files. I think you need to spend a little more time with themake
documentation. And when you do that I also recommend you learn more about implicit rules, which means you don't have to list the commands to build all object files.
– Some programmer dude
Nov 23 '18 at 11:37
You mean like wherever makefile is, it is a starting point ? and before each .cpp and .hpp files I should add the path like src/file_name.cpp ?@Someprogrammerdude
– casper
Nov 23 '18 at 11:42
Sure, just the file structure is the requirement for this assignment idk @Someprogrammerdude
– casper
Nov 23 '18 at 11:46
You could also usevpath %.hpp src
andvpath %.cpp src
– Botje
Nov 23 '18 at 11:56
1
vpath is an advanced Makefile use and often done wrong, don't start with that. For the header files pass "-I include" to g++ and for the cpp files use the full path, e.g. src/User.cpp. You should also make an agenda.o and add a separat linker stage. Once that works look into pattern rules: %.o: %.cpp for example.
– Goswin von Brederlow
Nov 23 '18 at 15:29
|
show 4 more comments
I have a C++ project with this file structure:
include files:
src files:
In order to compile it and run I'm trying to create simple Makefile. After going through some tutorials, that what i got so far:
vpath %.hpp include
vpath %.cpp src
agenda: agenda.cpp User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o
g++ agenda.cpp User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o -o agenda
User.o:User.hpp User.cpp
g++ -c -std=c++11 User.cpp
Date.o:Date.hpp Date.cpp
g++ -c -std=c++11 Date.cpp
Meeting.o:Meeting.hpp Meeting.cpp
g++ -c -std=c++11 Meeting.cpp
Storage.o:Storage.hpp Storage.cpp
g++ -c -std=c++11 Storage.cpp
AgendaService.o:AgendaService.hpp AgendaService.cpp
g++ -c -std=c++11 AgendaService.cpp
AgendaUI.o:AgendaUI.hpp AgendaUI.cpp
g++ -c -std=c++11 AgendaUI.cpp
clean:
rm User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o
And by the way, the main function here is agenda.cpp
file. So by executing the make
command I'm getting this error:
make: *** No rule to make target 'agenda.cpp', needed by 'agenda'. Stop.
My guess is it can't find the path to agenda.cpp otherwise it wouldn't ask to make a rule. Anyway not sure, hope someone could explain.
EDIT.0:
I have edited makefile by adding vpath, but still get the error(new):
g++ -c -std=c++11 User.cpp
g++: error: User.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
make: *** [makefile:9: User.o] Error 1
Seems like this time it found agenda.cpp
and User.hpp
but can't find User.cpp
. Really would appreciate any clue, was working on it for a long time.
EDIT.1:
#VPATH = src:include
#CPPFLAGS = -I include
#vpath %.hpp include
#vpath %.cpp src
bin/agenda: build/User.o build/Date.o build/Meeting.o build/Storage.o build/AgendaService.o build/AgendaUI.o
@mkdir -p bin
g++ -std=c++11 -w -I./include $^ -o $@
build/%.o: src/%.cpp
@mkdir -p build
g++ -std=c++11 -w -I./include -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
After spending some time on my Makefile, that is the final answer,it compiles fine all *.cpp files, stores obj file in build folder,no problem,except agenda.cpp(main-file),i didn't get my executable file. But got this error:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [makefile:8: bin/agenda] Error 1
How Could i fix this?
c++ makefile
I have a C++ project with this file structure:
include files:
src files:
In order to compile it and run I'm trying to create simple Makefile. After going through some tutorials, that what i got so far:
vpath %.hpp include
vpath %.cpp src
agenda: agenda.cpp User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o
g++ agenda.cpp User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o -o agenda
User.o:User.hpp User.cpp
g++ -c -std=c++11 User.cpp
Date.o:Date.hpp Date.cpp
g++ -c -std=c++11 Date.cpp
Meeting.o:Meeting.hpp Meeting.cpp
g++ -c -std=c++11 Meeting.cpp
Storage.o:Storage.hpp Storage.cpp
g++ -c -std=c++11 Storage.cpp
AgendaService.o:AgendaService.hpp AgendaService.cpp
g++ -c -std=c++11 AgendaService.cpp
AgendaUI.o:AgendaUI.hpp AgendaUI.cpp
g++ -c -std=c++11 AgendaUI.cpp
clean:
rm User.o Date.o Meeting.o Storage.o AgendaService.o AgendaUI.o
And by the way, the main function here is agenda.cpp
file. So by executing the make
command I'm getting this error:
make: *** No rule to make target 'agenda.cpp', needed by 'agenda'. Stop.
My guess is it can't find the path to agenda.cpp otherwise it wouldn't ask to make a rule. Anyway not sure, hope someone could explain.
EDIT.0:
I have edited makefile by adding vpath, but still get the error(new):
g++ -c -std=c++11 User.cpp
g++: error: User.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
make: *** [makefile:9: User.o] Error 1
Seems like this time it found agenda.cpp
and User.hpp
but can't find User.cpp
. Really would appreciate any clue, was working on it for a long time.
EDIT.1:
#VPATH = src:include
#CPPFLAGS = -I include
#vpath %.hpp include
#vpath %.cpp src
bin/agenda: build/User.o build/Date.o build/Meeting.o build/Storage.o build/AgendaService.o build/AgendaUI.o
@mkdir -p bin
g++ -std=c++11 -w -I./include $^ -o $@
build/%.o: src/%.cpp
@mkdir -p build
g++ -std=c++11 -w -I./include -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
After spending some time on my Makefile, that is the final answer,it compiles fine all *.cpp files, stores obj file in build folder,no problem,except agenda.cpp(main-file),i didn't get my executable file. But got this error:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [makefile:8: bin/agenda] Error 1
How Could i fix this?
c++ makefile
c++ makefile
edited Nov 24 '18 at 1:14
casper
asked Nov 23 '18 at 11:27
caspercasper
136
136
2
Remember that paths are relative. There is noagenda.cpp
file in the same directory asmakefile
. There is on the other hand asrc/agenda.cpp
file. The same problem with all your files. I think you need to spend a little more time with themake
documentation. And when you do that I also recommend you learn more about implicit rules, which means you don't have to list the commands to build all object files.
– Some programmer dude
Nov 23 '18 at 11:37
You mean like wherever makefile is, it is a starting point ? and before each .cpp and .hpp files I should add the path like src/file_name.cpp ?@Someprogrammerdude
– casper
Nov 23 '18 at 11:42
Sure, just the file structure is the requirement for this assignment idk @Someprogrammerdude
– casper
Nov 23 '18 at 11:46
You could also usevpath %.hpp src
andvpath %.cpp src
– Botje
Nov 23 '18 at 11:56
1
vpath is an advanced Makefile use and often done wrong, don't start with that. For the header files pass "-I include" to g++ and for the cpp files use the full path, e.g. src/User.cpp. You should also make an agenda.o and add a separat linker stage. Once that works look into pattern rules: %.o: %.cpp for example.
– Goswin von Brederlow
Nov 23 '18 at 15:29
|
show 4 more comments
2
Remember that paths are relative. There is noagenda.cpp
file in the same directory asmakefile
. There is on the other hand asrc/agenda.cpp
file. The same problem with all your files. I think you need to spend a little more time with themake
documentation. And when you do that I also recommend you learn more about implicit rules, which means you don't have to list the commands to build all object files.
– Some programmer dude
Nov 23 '18 at 11:37
You mean like wherever makefile is, it is a starting point ? and before each .cpp and .hpp files I should add the path like src/file_name.cpp ?@Someprogrammerdude
– casper
Nov 23 '18 at 11:42
Sure, just the file structure is the requirement for this assignment idk @Someprogrammerdude
– casper
Nov 23 '18 at 11:46
You could also usevpath %.hpp src
andvpath %.cpp src
– Botje
Nov 23 '18 at 11:56
1
vpath is an advanced Makefile use and often done wrong, don't start with that. For the header files pass "-I include" to g++ and for the cpp files use the full path, e.g. src/User.cpp. You should also make an agenda.o and add a separat linker stage. Once that works look into pattern rules: %.o: %.cpp for example.
– Goswin von Brederlow
Nov 23 '18 at 15:29
2
2
Remember that paths are relative. There is no
agenda.cpp
file in the same directory as makefile
. There is on the other hand a src/agenda.cpp
file. The same problem with all your files. I think you need to spend a little more time with the make
documentation. And when you do that I also recommend you learn more about implicit rules, which means you don't have to list the commands to build all object files.– Some programmer dude
Nov 23 '18 at 11:37
Remember that paths are relative. There is no
agenda.cpp
file in the same directory as makefile
. There is on the other hand a src/agenda.cpp
file. The same problem with all your files. I think you need to spend a little more time with the make
documentation. And when you do that I also recommend you learn more about implicit rules, which means you don't have to list the commands to build all object files.– Some programmer dude
Nov 23 '18 at 11:37
You mean like wherever makefile is, it is a starting point ? and before each .cpp and .hpp files I should add the path like src/file_name.cpp ?@Someprogrammerdude
– casper
Nov 23 '18 at 11:42
You mean like wherever makefile is, it is a starting point ? and before each .cpp and .hpp files I should add the path like src/file_name.cpp ?@Someprogrammerdude
– casper
Nov 23 '18 at 11:42
Sure, just the file structure is the requirement for this assignment idk @Someprogrammerdude
– casper
Nov 23 '18 at 11:46
Sure, just the file structure is the requirement for this assignment idk @Someprogrammerdude
– casper
Nov 23 '18 at 11:46
You could also use
vpath %.hpp src
and vpath %.cpp src
– Botje
Nov 23 '18 at 11:56
You could also use
vpath %.hpp src
and vpath %.cpp src
– Botje
Nov 23 '18 at 11:56
1
1
vpath is an advanced Makefile use and often done wrong, don't start with that. For the header files pass "-I include" to g++ and for the cpp files use the full path, e.g. src/User.cpp. You should also make an agenda.o and add a separat linker stage. Once that works look into pattern rules: %.o: %.cpp for example.
– Goswin von Brederlow
Nov 23 '18 at 15:29
vpath is an advanced Makefile use and often done wrong, don't start with that. For the header files pass "-I include" to g++ and for the cpp files use the full path, e.g. src/User.cpp. You should also make an agenda.o and add a separat linker stage. Once that works look into pattern rules: %.o: %.cpp for example.
– Goswin von Brederlow
Nov 23 '18 at 15:29
|
show 4 more comments
1 Answer
1
active
oldest
votes
Alright i made this Makefile
and it compiles and runs just fine, just post it here if someone needs that as a reference.
The study path that i used is:
GNU tutorials
(.text+0x20): undefined reference to `main' and undefined reference to function
C Linking Error: undefined reference to 'main'
CC := g++
FLAGS := -std=c++11 -w
BIN_DIR := bin
INC_DIR := include
SRC_DIR := src
INCLUDE := -I./$(INC_DIR)
BUILD_DIR := build
$(BIN_DIR)/agenda: $(BUILD_DIR)/User.o $(BUILD_DIR)/Date.o $(BUILD_DIR)/Meeting.o $(BUILD_DIR)/Storage.o $(BUILD_DIR)/AgendaService.o $(BUILD_DIR)/AgendaUI.o $(BUILD_DIR)/agenda.o
@mkdir -p $(BIN_DIR)
$(CC) $(FLAGS) $(INCLUDE) $^ -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(BUILD_DIR)
$(CC) $(FLAGS) $(INCLUDE) -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445850%2fmake-no-rule-to-make-target-agenda-cpp-needed-by-agenda-stop-making%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Alright i made this Makefile
and it compiles and runs just fine, just post it here if someone needs that as a reference.
The study path that i used is:
GNU tutorials
(.text+0x20): undefined reference to `main' and undefined reference to function
C Linking Error: undefined reference to 'main'
CC := g++
FLAGS := -std=c++11 -w
BIN_DIR := bin
INC_DIR := include
SRC_DIR := src
INCLUDE := -I./$(INC_DIR)
BUILD_DIR := build
$(BIN_DIR)/agenda: $(BUILD_DIR)/User.o $(BUILD_DIR)/Date.o $(BUILD_DIR)/Meeting.o $(BUILD_DIR)/Storage.o $(BUILD_DIR)/AgendaService.o $(BUILD_DIR)/AgendaUI.o $(BUILD_DIR)/agenda.o
@mkdir -p $(BIN_DIR)
$(CC) $(FLAGS) $(INCLUDE) $^ -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(BUILD_DIR)
$(CC) $(FLAGS) $(INCLUDE) -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
add a comment |
Alright i made this Makefile
and it compiles and runs just fine, just post it here if someone needs that as a reference.
The study path that i used is:
GNU tutorials
(.text+0x20): undefined reference to `main' and undefined reference to function
C Linking Error: undefined reference to 'main'
CC := g++
FLAGS := -std=c++11 -w
BIN_DIR := bin
INC_DIR := include
SRC_DIR := src
INCLUDE := -I./$(INC_DIR)
BUILD_DIR := build
$(BIN_DIR)/agenda: $(BUILD_DIR)/User.o $(BUILD_DIR)/Date.o $(BUILD_DIR)/Meeting.o $(BUILD_DIR)/Storage.o $(BUILD_DIR)/AgendaService.o $(BUILD_DIR)/AgendaUI.o $(BUILD_DIR)/agenda.o
@mkdir -p $(BIN_DIR)
$(CC) $(FLAGS) $(INCLUDE) $^ -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(BUILD_DIR)
$(CC) $(FLAGS) $(INCLUDE) -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
add a comment |
Alright i made this Makefile
and it compiles and runs just fine, just post it here if someone needs that as a reference.
The study path that i used is:
GNU tutorials
(.text+0x20): undefined reference to `main' and undefined reference to function
C Linking Error: undefined reference to 'main'
CC := g++
FLAGS := -std=c++11 -w
BIN_DIR := bin
INC_DIR := include
SRC_DIR := src
INCLUDE := -I./$(INC_DIR)
BUILD_DIR := build
$(BIN_DIR)/agenda: $(BUILD_DIR)/User.o $(BUILD_DIR)/Date.o $(BUILD_DIR)/Meeting.o $(BUILD_DIR)/Storage.o $(BUILD_DIR)/AgendaService.o $(BUILD_DIR)/AgendaUI.o $(BUILD_DIR)/agenda.o
@mkdir -p $(BIN_DIR)
$(CC) $(FLAGS) $(INCLUDE) $^ -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(BUILD_DIR)
$(CC) $(FLAGS) $(INCLUDE) -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
Alright i made this Makefile
and it compiles and runs just fine, just post it here if someone needs that as a reference.
The study path that i used is:
GNU tutorials
(.text+0x20): undefined reference to `main' and undefined reference to function
C Linking Error: undefined reference to 'main'
CC := g++
FLAGS := -std=c++11 -w
BIN_DIR := bin
INC_DIR := include
SRC_DIR := src
INCLUDE := -I./$(INC_DIR)
BUILD_DIR := build
$(BIN_DIR)/agenda: $(BUILD_DIR)/User.o $(BUILD_DIR)/Date.o $(BUILD_DIR)/Meeting.o $(BUILD_DIR)/Storage.o $(BUILD_DIR)/AgendaService.o $(BUILD_DIR)/AgendaUI.o $(BUILD_DIR)/agenda.o
@mkdir -p $(BIN_DIR)
$(CC) $(FLAGS) $(INCLUDE) $^ -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(BUILD_DIR)
$(CC) $(FLAGS) $(INCLUDE) -c -o $@ $<
clean:
@rm -rf build
@rm -rf bin
answered Nov 24 '18 at 2:37
caspercasper
136
136
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445850%2fmake-no-rule-to-make-target-agenda-cpp-needed-by-agenda-stop-making%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Remember that paths are relative. There is no
agenda.cpp
file in the same directory asmakefile
. There is on the other hand asrc/agenda.cpp
file. The same problem with all your files. I think you need to spend a little more time with themake
documentation. And when you do that I also recommend you learn more about implicit rules, which means you don't have to list the commands to build all object files.– Some programmer dude
Nov 23 '18 at 11:37
You mean like wherever makefile is, it is a starting point ? and before each .cpp and .hpp files I should add the path like src/file_name.cpp ?@Someprogrammerdude
– casper
Nov 23 '18 at 11:42
Sure, just the file structure is the requirement for this assignment idk @Someprogrammerdude
– casper
Nov 23 '18 at 11:46
You could also use
vpath %.hpp src
andvpath %.cpp src
– Botje
Nov 23 '18 at 11:56
1
vpath is an advanced Makefile use and often done wrong, don't start with that. For the header files pass "-I include" to g++ and for the cpp files use the full path, e.g. src/User.cpp. You should also make an agenda.o and add a separat linker stage. Once that works look into pattern rules: %.o: %.cpp for example.
– Goswin von Brederlow
Nov 23 '18 at 15:29