我试图编译使用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