我想讓我的makefile工作,但它給了我一些錯誤,我無法讓它工作。Makefile不起作用
OBJS = Kmeans.o cluster.o data.o
CC = g++
DEBUG = -g
CFLAGS = -Wall -c $(DEBUG)
LFLAGS = -Wall $(DEBUG)
clustering : $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o clustering
Kmeans.o : Kmeans.h Kmeans.cpp cluster.h data.h
$(CC) $(CFLAGS) Kmeans.cpp
cluster.o : cluster.h cluster.cpp data.h
$(CC) $(CFLAGS) cluster.cpp
data.o : data.h data.cpp
$(CC) $(CFLAGS) data.cpp
clean:
\rm *.o *~ clustering
而且文件是:
clustering.cpp -> #include "Kmeans.h"
Kmeans.cpp -> #include "Kmeans.h"
Kmeans.h -> #include "cluster.h"
cluster.cpp -> #include "cluster.h"
cluster.h -> #include "data.h"
data.cpp -> #include "data.h"
我在做什麼錯?
編輯: 對不起,我忘了,包括錯誤:
Kmeans.o: In function `Kmeans::read(char*)':
Kmeans.cpp:(.text+0x53c): undefined reference to `Data::~Data()'
cluster.o: In function `Cluster::Cluster(int, int, int)':
cluster.cpp:(.text+0x45): undefined reference to `Data::~Data()'
cluster.cpp:(.text+0x80): undefined reference to `Data::~Data()'
cluster.o: In function `Cluster::Cluster()':
cluster.cpp:(.text+0xca): undefined reference to `Data::~Data()'
cluster.cpp:(.text+0x110): undefined reference to `Data::~Data()'
cluster.o: In function `Cluster::setData(int, int, int)':
cluster.cpp:(.text+0x158): undefined reference to `Data::~Data()'
collect2: ld devolvió el estado de salida 1
make: *** [clustering] Error 1
謝謝!
我編譯每個文件和問題是在最後一行:似乎
g++ -c -o clustering.o clustering.cpp
g++ -c -o data.o data.cpp
g++ -c -o Kmeans.o Kmeans.cpp
g++ -c -o cluster.o cluster.cpp
g++ -o clustering clustering.o data.o Kmeans.o cluster.o <----
*請問什麼*錯誤? –