我試圖編譯使用2個.cc的文件和.H簡單的makefile問題
我正在寫一個Makefile,但它不是編譯一個項目,我得到一個錯誤:
make
g++ -I/usr/local/include/ -I/usr/local/include/libfreenect -I. -I/usr/include/GL -fPIC -g -Wall `pkg-config --cflags opencv` -L/usr/X11R6/lib -L/usr/lib -L/lib simple_gesture.cc -o simple_gesture `pkg-config --libs opencv` -L/usr/local/lib -lfreenect -lglui -lglut -lGLU -lGL
simple_gesture.cc: In function ‘void depth_cb(freenect_device*, void*, uint32_t)’:
simple_gesture.cc:315: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘clock_t’
simple_gesture.cc:315: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’
/tmp/cck2APvc.o: In function `depth_cb(_freenect_device*, void*, unsigned int)':
/home/dany/ToCompile/kinect-apps-playground-fingertip-detection/simple_gesture.cc:313: undefined reference to `FeatureExtractor::Process(unsigned char*, int const*, int)'
collect2: ld returned 1 exit status
make: *** [simple_gesture] Error 1
Makefile的是這樣的:
all: simple_gesture
CFLAGS=-fPIC -g -Wall `pkg-config --cflags opencv`
LIBS = `pkg-config --libs opencv`
INCLUDE = -I/usr/local/include/ -I/usr/local/include/libfreenect -I. -I/usr/include/GL
FREE_LIBS = -L/usr/local/lib -lfreenect
GL_LIBS = -lglui -lglut -lGLU -lGL
GL_FLAGS = -L/usr/X11R6/lib -L/usr/lib -L/lib
feature_extractor: feature_extractor.h feature_extractor.cc
$(CXX) $(INCLUDE) $(CFLAGS) $(GL_FLAGS) $? -o [email protected] $(LIBS) $(FREE_LIBS) $(GL_LIBS)
simple_gesture: simple_gesture.cc
$(CXX) $(INCLUDE) $(CFLAGS) $(GL_FLAGS) $? -o [email protected] $(LIBS) $(FREE_LIBS) $(GL_LIBS)
%.o: %.c
$(CXX) -c $(CFLAGS) $< -o [email protected]
clean:
rm -rf *.o feature_extractor simple_gesture
我覺得我沒有縫好了的文件..
任何想法?
[編輯] 解決
這已經足夠了:
simple_gesture:feature_extractor.h feature_extractor.cc simple_gesture.cc $(CXX)$(含)$(CFLAGS)$(GL_FLAGS)$ ? -o $ @ $(LIBS)$(FREE_LIBS)$(GL_LIBS)
什麼是過程()函數feature_extractor?錯誤是鏈接錯誤,所以你可能需要包含另一個文件。 – MByD 2011-03-11 13:01:10
是進程是feature_extractor。我不認爲我需要另一個包含,我認爲問題只是Makefile,因爲這個代碼也被其他人使用 – azinos 2011-03-11 14:07:56