質問編集履歴

4

文章を修正

2021/09/16 08:03

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -62,23 +62,23 @@
62
62
 
63
63
  PRG :=AAEditor
64
64
 
65
- SRCDIR :=source
65
+ SRC_DIR :=source
66
-
66
+
67
- OBJDIR :=obj
67
+ OBJ_DIR :=obj
68
-
68
+
69
- DEPDIR :=obj
69
+ DEP_DIR :=obj
70
-
70
+
71
- DEP :=$(wildcard $(DEPDIR)/*.d)
71
+ DEP :=$(wildcard $(DEP_DIR)/*.d)
72
-
72
+
73
- SRC :=$(wildcard $(SRCDIR)/*.cpp)
73
+ SRC :=$(wildcard $(SRC_DIR)/*.cpp)
74
-
74
+
75
- OBJ :=$(addprefix $(OBJDIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC))))
75
+ OBJ :=$(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC))))
76
-
77
-
78
-
76
+
77
+
78
+
79
- $(warning SRC = $(SRC));
79
+ #$(warning SRC = $(SRC)); #デバッグ
80
-
80
+
81
- $(warning OBJ = $(OBJ));
81
+ #$(warning OBJ = $(OBJ)); #デバッグ
82
82
 
83
83
 
84
84
 
@@ -90,7 +90,7 @@
90
90
 
91
91
 
92
92
 
93
- $(OBJDIR)/%.o: source/%.cpp
93
+ $(OBJ_DIR)/%.o: source/%.cpp
94
94
 
95
95
  $(CXX) -c -MMD -MP $^ -o $@
96
96
 
@@ -100,9 +100,7 @@
100
100
 
101
101
  clean:
102
102
 
103
- rm -f ./obj/*.o *.out ./obj/*.d *.a $(PRG)
103
+ rm -f ./$(OBJ_DIR)/*.o *.out ./$(OBJ_DIR)/*.d *.a $(PRG)
104
-
105
-
106
104
 
107
105
  ```
108
106
 

3

文章を修正

2021/09/16 08:03

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -74,6 +74,16 @@
74
74
 
75
75
  OBJ :=$(addprefix $(OBJDIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC))))
76
76
 
77
+
78
+
79
+ $(warning SRC = $(SRC));
80
+
81
+ $(warning OBJ = $(OBJ));
82
+
83
+
84
+
85
+
86
+
77
87
  $(PRG): $(OBJ)
78
88
 
79
89
  $(CXX) $^ -l ncurses -o $@
@@ -128,6 +138,10 @@
128
138
 
129
139
  makefile を読み込みます...
130
140
 
141
+ Makefile:11: SRC = source/Fps.cpp source/Color.cpp source/Scene.cpp source/Entry.cpp source/Main.cpp source/Screen.cpp source/Log.cpp source/Edit.cpp
142
+
143
+ Makefile:12: OBJ = obj/Fps.o obj/Color.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o
144
+
131
145
  makefile の更新中....
132
146
 
133
147
  最終ターゲットを更新中....
@@ -136,11 +150,19 @@
136
150
 
137
151
  ターゲット 'AAEditor' を再make する必要があります.
138
152
 
139
- g++ obj/Fps.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o -l ncurses -o AAEditor
153
+ g++ obj/Fps.o obj/Color.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o -l ncurses -o AAEditor
140
-
154
+
141
- /usr/bin/ld: obj/Main.o: in function `main':
155
+ /usr/bin/ld: obj/Color.o: in function `InitColorPairs()':
142
-
156
+
143
- Main.cpp:(.text+0x62): undefined reference to `InitColorPairs()'
157
+ Color.cpp:(.text+0xdf): undefined reference to `GetColorNum(int, int)'
158
+
159
+ /usr/bin/ld: obj/Color.o: in function `SetColor(int, int)':
160
+
161
+ Color.cpp:(.text+0x140): undefined reference to `GetColorNum(int, int)'
162
+
163
+ /usr/bin/ld: obj/Color.o: in function `UnSetColor(int, int)':
164
+
165
+ Color.cpp:(.text+0x1af): undefined reference to `GetColorNum(int, int)'
144
166
 
145
167
  /usr/bin/ld: obj/Screen.o: in function `Screen::Screen()':
146
168
 
@@ -150,55 +172,43 @@
150
172
 
151
173
  Screen.cpp:(.text+0x331): undefined reference to `GetColorNum(int, int)'
152
174
 
153
- /usr/bin/ld: obj/Screen.o: in function `Screen::Delete(int, int)':
154
-
155
- Screen.cpp:(.text+0x47b): undefined reference to `GetColorNum(int, int)'
156
-
157
- /usr/bin/ld: obj/Edit.o: in function `Edit::KeyInput()':
158
-
159
- Edit.cpp:(.text+0x1bc): undefined reference to `GetColorNum(int, int)'
160
-
161
- /usr/bin/ld: obj/Edit.o: in function `Edit::MouseInput()':
162
-
163
- Edit.cpp:(.text+0x348): undefined reference to `GetColorNum(int, int)'
164
-
165
- /usr/bin/ld: obj/Edit.o:Edit.cpp:(.text+0x3f6): more undefined references to `GetColorNum(int, int)' follow
175
+ /usr/bin/ld: obj/Screen.o:Screen.cpp:(.text+0x47b): more undefined references to `GetColorNum(int, int)' follow
166
176
 
167
177
  collect2: error: ld returned 1 exit status
168
178
 
169
- make: *** [Makefile:9: AAEditor] エラー 1
179
+ make: *** [Makefile:16: AAEditor] エラー 1
170
-
171
-
172
-
180
+
181
+
182
+
183
+
184
+
173
- ```
185
+ ```
174
-
175
-
176
-
186
+
187
+
188
+
177
- make clean 後再度実行
189
+ make clean 後再度実行 $(warning)関数を利用
178
190
 
179
191
  ```
180
192
 
181
193
  $ make
182
194
 
183
- g++ -c -MMD -MP source/Fps.cpp -o obj/Fps.o
184
-
185
- g++ -c -MMD -MP source/Scene.cpp -o obj/Scene.o
195
+ Makefile:11: SRC = source/Fps.cpp source/Color.cpp source/Scene.cpp source/Entry.cpp source/Main.cpp source/Screen.cpp source/Log.cpp source/Edit.cpp
186
-
187
- g++ -c -MMD -MP source/Entry.cpp -o obj/Entry.o
196
+
188
-
189
- g++ -c -MMD -MP source/Main.cpp -o obj/Main.o
190
-
191
- g++ -c -MMD -MP source/Screen.cpp -o obj/Screen.o
197
+ Makefile:12: OBJ = obj/Fps.o obj/Color.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o
192
-
193
- g++ -c -MMD -MP source/Log.cpp -o obj/Log.o
198
+
194
-
195
- g++ -c -MMD -MP source/Edit.cpp -o obj/Edit.o
196
-
197
- g++ obj/Fps.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o -l ncurses -o AAEditor
199
+ g++ obj/Fps.o obj/Color.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o -l ncurses -o AAEditor
198
-
200
+
199
- /usr/bin/ld: obj/Main.o: in function `main':
201
+ /usr/bin/ld: obj/Color.o: in function `InitColorPairs()':
200
-
202
+
201
- Main.cpp:(.text+0x62): undefined reference to `InitColorPairs()'
203
+ Color.cpp:(.text+0xdf): undefined reference to `GetColorNum(int, int)'
204
+
205
+ /usr/bin/ld: obj/Color.o: in function `SetColor(int, int)':
206
+
207
+ Color.cpp:(.text+0x140): undefined reference to `GetColorNum(int, int)'
208
+
209
+ /usr/bin/ld: obj/Color.o: in function `UnSetColor(int, int)':
210
+
211
+ Color.cpp:(.text+0x1af): undefined reference to `GetColorNum(int, int)'
202
212
 
203
213
  /usr/bin/ld: obj/Screen.o: in function `Screen::Screen()':
204
214
 
@@ -208,66 +218,10 @@
208
218
 
209
219
  Screen.cpp:(.text+0x331): undefined reference to `GetColorNum(int, int)'
210
220
 
211
- /usr/bin/ld: obj/Screen.o: in function `Screen::Delete(int, int)':
212
-
213
- Screen.cpp:(.text+0x47b): undefined reference to `GetColorNum(int, int)'
214
-
215
- /usr/bin/ld: obj/Edit.o: in function `Edit::KeyInput()':
216
-
217
- Edit.cpp:(.text+0x1bc): undefined reference to `GetColorNum(int, int)'
218
-
219
- /usr/bin/ld: obj/Edit.o: in function `Edit::MouseInput()':
220
-
221
- Edit.cpp:(.text+0x348): undefined reference to `GetColorNum(int, int)'
222
-
223
- /usr/bin/ld: obj/Edit.o:Edit.cpp:(.text+0x3f6): more undefined references to `GetColorNum(int, int)' follow
221
+ /usr/bin/ld: obj/Screen.o:Screen.cpp:(.text+0x47b): more undefined references to `GetColorNum(int, int)' follow
224
222
 
225
223
  collect2: error: ld returned 1 exit status
226
224
 
227
- make: *** [Makefile:9: AAEditor] エラー 1
228
-
229
-
230
-
231
- ```
232
-
233
- $(warning)関数を利用 ** **強調部に存在しています。
234
-
235
- ```
236
-
237
- $ make
238
-
239
- Makefile:11: SRC = source/Fps.cpp **source/Color.cpp** source/Scene.cpp source/Entry.cpp source/Main.cpp source/Screen.cpp source/Log.cpp source/Edit.cpp
240
-
241
- Makefile:12: OBJ = obj/Fps.o **obj/Color.o** obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o
242
-
243
- g++ obj/Fps.o obj/Color.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o -l ncurses -o AAEditor
244
-
245
-
246
-
247
- /usr/bin/ld: obj/Color.o: in function `InitColorPairs()':
248
-
249
- Color.cpp:(.text+0xdf): undefined reference to `GetColorNum(int, int)'
250
-
251
- /usr/bin/ld: obj/Color.o: in function `SetColor(int, int)':
252
-
253
- Color.cpp:(.text+0x140): undefined reference to `GetColorNum(int, int)'
254
-
255
- /usr/bin/ld: obj/Color.o: in function `UnSetColor(int, int)':
256
-
257
- Color.cpp:(.text+0x1af): undefined reference to `GetColorNum(int, int)'
258
-
259
- /usr/bin/ld: obj/Screen.o: in function `Screen::Screen()':
260
-
261
- Screen.cpp:(.text+0x1cc): undefined reference to `GetColorNum(int, int)'
262
-
263
- /usr/bin/ld: obj/Screen.o: in function `Screen::UpdateScreen()':
264
-
265
- Screen.cpp:(.text+0x331): undefined reference to `GetColorNum(int, int)'
266
-
267
- /usr/bin/ld: obj/Screen.o:Screen.cpp:(.text+0x47b): more undefined references to `GetColorNum(int, int)' follow
268
-
269
- collect2: error: ld returned 1 exit status
270
-
271
225
  make: *** [Makefile:16: AAEditor] エラー 1
272
226
 
273
227
 

2

文章を修正

2021/09/16 07:37

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -4,6 +4,14 @@
4
4
 
5
5
 
6
6
 
7
+
8
+
9
+ 参考サイトA: [https://qiita.com/aosho235/items/8e90bf09795758cfb70b
10
+
11
+ ](https://qiita.com/aosho235/items/8e90bf09795758cfb70b)
12
+
13
+
14
+
7
15
  ```makefile
8
16
 
9
17
  g++ obj/Fps.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o -l ncurses -o AAEditor
@@ -38,6 +46,18 @@
38
46
 
39
47
 
40
48
 
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
41
61
  ```makefile
42
62
 
43
63
  PRG :=AAEditor
@@ -209,3 +229,47 @@
209
229
 
210
230
 
211
231
  ```
232
+
233
+ $(warning)関数を利用 ** **強調部に存在しています。
234
+
235
+ ```
236
+
237
+ $ make
238
+
239
+ Makefile:11: SRC = source/Fps.cpp **source/Color.cpp** source/Scene.cpp source/Entry.cpp source/Main.cpp source/Screen.cpp source/Log.cpp source/Edit.cpp
240
+
241
+ Makefile:12: OBJ = obj/Fps.o **obj/Color.o** obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o
242
+
243
+ g++ obj/Fps.o obj/Color.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o -l ncurses -o AAEditor
244
+
245
+
246
+
247
+ /usr/bin/ld: obj/Color.o: in function `InitColorPairs()':
248
+
249
+ Color.cpp:(.text+0xdf): undefined reference to `GetColorNum(int, int)'
250
+
251
+ /usr/bin/ld: obj/Color.o: in function `SetColor(int, int)':
252
+
253
+ Color.cpp:(.text+0x140): undefined reference to `GetColorNum(int, int)'
254
+
255
+ /usr/bin/ld: obj/Color.o: in function `UnSetColor(int, int)':
256
+
257
+ Color.cpp:(.text+0x1af): undefined reference to `GetColorNum(int, int)'
258
+
259
+ /usr/bin/ld: obj/Screen.o: in function `Screen::Screen()':
260
+
261
+ Screen.cpp:(.text+0x1cc): undefined reference to `GetColorNum(int, int)'
262
+
263
+ /usr/bin/ld: obj/Screen.o: in function `Screen::UpdateScreen()':
264
+
265
+ Screen.cpp:(.text+0x331): undefined reference to `GetColorNum(int, int)'
266
+
267
+ /usr/bin/ld: obj/Screen.o:Screen.cpp:(.text+0x47b): more undefined references to `GetColorNum(int, int)' follow
268
+
269
+ collect2: error: ld returned 1 exit status
270
+
271
+ make: *** [Makefile:16: AAEditor] エラー 1
272
+
273
+
274
+
275
+ ```

1

文章を修正

2021/09/16 07:13

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- makefile 特定のソースファイルだけオブジェクトファイルが生成されない原因が知りたい
1
+ makefile 特定のオブジェクトファイルがg++ コマンドの行に乗らない生成されない原因が知りたい
test CHANGED
@@ -1,8 +1,14 @@
1
- 提示コードのmakefileですがsource/%.cppを使ってsourceディレクトリファイルを全部見ているのですが なぜColor.cppだけオブジェトファイルが生成されないのでしょうか?ワイルドカードを使っているのでディレクトリ内全部がパイル対象のはずです。
1
+ 提示コードのmakefileですがsource/%.cppを使ってsourceディレクトリファイルを全部見ているのですが なぜColor.oだけg++のリンコマンドに乗らないのでしょうか?ワイルドカードを使っているのでディレクトリ内全部が対象のはずです。
2
+
3
+
4
+
5
+
6
+
2
-
7
+ ```makefile
8
+
3
-
9
+ g++ obj/Fps.o obj/Scene.o obj/Entry.o obj/Main.o obj/Screen.o obj/Log.o obj/Edit.o -l ncurses -o AAEditor
10
+
4
-
11
+ ```
5
-
6
12
 
7
13
 
8
14