help!!!]静态编译opencv程序“人脸检测系统”出错

时间:2021-09-12 19:28:57
我的Makefile如下:


INCLUDEPATH=/usr/local/include/opencv

LIBS+=/usr/local/lib/libhighgui.a /usr/local/lib/libcv.a /usr/local/lib/libcxcore.a \
/usr/local/lib/libcvaux.a /usr/local/lib/libml.a \
/usr/local/lib/libgtk-x11-2.0.a /usr/local/lib/libgdk-x11-2.0.a \
/usr/local/lib/libgobject-2.0.a /usr/local/lib/libglib-2.0.a \
/usr/local/lib/libgthread-2.0.a \
/usr/local/lib/libpng.a /usr/local/lib/libjpeg.a /usr/local/lib/libtiff.a \
/usr/lib/libpthread.a 

facedect: facedect.cpp facedect.h
g++ -I$(INCLUDEPATH) facedect.cpp facedect.h -o facedect $(LIBS)

结果出一堆错误:
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `GrFmtJpeg2000Writer::WriteComponent16u(jas_image_t*, unsigned short const*, int, int, int, int)':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:481: undefined reference to `jas_matrix_create'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:491: undefined reference to `jas_image_writecmpt'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:495: undefined reference to `jas_matrix_destroy'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `GrFmtJpeg2000Writer::WriteComponent8u(jas_image_t*, unsigned char const*, int, int, int, int)':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:458: undefined reference to `jas_matrix_create'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:468: undefined reference to `jas_image_writecmpt'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:472: undefined reference to `jas_matrix_destroy'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `GrFmtJpeg2000Writer::WriteImage(unsigned char const*, int, int, int, int, int)':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:420: undefined reference to `jas_image_create'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:449: undefined reference to `jas_image_destroy'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:440: undefined reference to `jas_stream_fopen'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:443: undefined reference to `jas_image_strtofmt'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:443: undefined reference to `jas_image_encode'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:445: undefined reference to `jas_stream_close'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `GrFmtJpeg2000Reader::ReadHeader()':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:113: undefined reference to `jas_stream_fopen'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:116: undefined reference to `jas_image_decode'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `GrFmtJpeg2000Reader::Close()':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:94: undefined reference to `jas_stream_close'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:100: undefined reference to `jas_image_destroy'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `GrFmtJpeg2000Reader::ReadData(unsigned char*, int, int)':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:202: undefined reference to `jas_image_getcmptbytype'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:203: undefined reference to `jas_image_getcmptbytype'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:204: undefined reference to `jas_image_getcmptbytype'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:188: undefined reference to `jas_cmprof_destroy'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `GrFmtJpeg2000':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:54: undefined reference to `jas_init'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `~GrFmtJpeg2000':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:60: undefined reference to `jas_cleanup'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `GrFmtJpeg2000':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:54: undefined reference to `jas_init'
/usr/local/lib/libhighgui.a(grfmt_jpeg2000.o): In function `~GrFmtJpeg2000':
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:60: undefined reference to `jas_cleanup'
/home/hua/opencv-1.0.0/otherlibs/highgui/grfmt_jpeg2000.cpp:60: undefined reference to `jas_cleanup'
/usr/local/lib/libgtk-x11-2.0.a(gtkbox.o): In function `IA__gtk_box_set_spacing':
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:489: undefined reference to `g_object_notify'
/usr/local/lib/libgtk-x11-2.0.a(gtkbox.o): In function `IA__gtk_box_set_homogeneous':
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:458: undefined reference to `g_object_notify'
/usr/local/lib/libgtk-x11-2.0.a(gtkbox.o): In function `gtk_box_class_init':
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:128: undefined reference to `g_object_class_install_property'
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:138: undefined reference to `g_object_class_install_property'
/usr/local/lib/libgtk-x11-2.0.a(gtkbox.o): In function `gtk_box_get_child_property':
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:357: undefined reference to `g_value_set_int'
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:335: undefined reference to `g_value_set_boolean'
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:344: undefined reference to `g_value_set_enum'
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:341: undefined reference to `g_value_set_uint'
/home/hua/gtk+-2.8.20/gtk/gtkbox.c:338: undefined reference to `g_value_set_boolean'
/usr/local/lib/libgtk-x11-2.0.a(gtkcontainer.o): In function `IA__gtk_container_child_get_valist':
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:362: undefined reference to `g_object_ref'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:363: undefined reference to `g_object_ref'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:372: undefined reference to `g_param_spec_pool_lookup'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:392: undefined reference to `g_value_init'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:402: undefined reference to `g_value_unset'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:406: undefined reference to `g_object_unref'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:407: undefined reference to `g_object_unref'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:399: undefined reference to `g_value_unset'
/usr/local/lib/libgtk-x11-2.0.a(gtkcontainer.o): In function `gtk_container_class_init':
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:202: undefined reference to `g_object_class_install_property'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:210: undefined reference to `g_object_class_install_property'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:219: undefined reference to `g_object_class_install_property'
/usr/local/lib/libgtk-x11-2.0.a(gtkcontainer.o): In function `gtk_container_real_set_focus_child':
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:1469: undefined reference to `g_object_unref'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:1472: undefined reference to `g_object_ref'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:1485: undefined reference to `g_object_get_qdata'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:1486: undefined reference to `g_object_get_qdata'
/usr/local/lib/libgtk-x11-2.0.a(gtkcontainer.o): In function `gtk_container_set_property':
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:849: undefined reference to `g_value_get_enum'
/home/hua/gtk+-2.8.20/gtk/gtkcontainer.c:852: undefined reference to 
................................大概有5000千多行.............

   有人知道这是为什么吗?还缺什么库吗?我的静态库顺序错了吗?

7 个解决方案

#1


-I$变成-I $试试

不是库文件吧,好象是头文件的事

#2


错误已经发现了改变,看来我的头文件指定也有问题呀

#3


把LIBS改成下面试试:
LIBS+= -Wl,--startgroup /usr/local/lib/libhighgui.a /usr/local/lib/libcv.a /usr/local/lib/libcxcore.a \
/usr/local/lib/libcvaux.a /usr/local/lib/libml.a \
/usr/local/lib/libgtk-x11-2.0.a /usr/local/lib/libgdk-x11-2.0.a \
/usr/local/lib/libgobject-2.0.a /usr/local/lib/libglib-2.0.a \
/usr/local/lib/libgthread-2.0.a \
/usr/local/lib/libpng.a /usr/local/lib/libjpeg.a /usr/local/lib/libtiff.a \
/usr/lib/libpthread.a  -Wl,--endgroup

#4


facedect.h:1:16: error: cv.h: No such file or directory
facedect.h:2:21: error: highgui.h: No such file or directory

#5


     不对呀,我的/usr/local/include/opencv 是有cv.h和highgui.h的。
/usr/local/include/opencv # ls
cv.h    cvaux.h    cvcompat.h        cvmat.hpp  cvver.h        cxcore.h    cxerror.h  cxtypes.h  ml.h
cv.hpp  cvaux.hpp  cvhaartraining.h  cvtypes.h  cvvidsurv.hpp  cxcore.hpp  cxmisc.h    highgui.h

#6


是不是因为我同时指定了多个include路径呀?这种写法不正确。
INCLUDEPATH=/usr/local/include/opencv:/usr/local/include/opencvgtk-2.0:/usr/local/include/glib-2.0:/usr/local/include/cairo:/usr/local/include/pango-1.0

#7


有没有大牛指点下哈。。。。搬板凳学习中。。。。

#1


-I$变成-I $试试

不是库文件吧,好象是头文件的事

#2


错误已经发现了改变,看来我的头文件指定也有问题呀

#3


把LIBS改成下面试试:
LIBS+= -Wl,--startgroup /usr/local/lib/libhighgui.a /usr/local/lib/libcv.a /usr/local/lib/libcxcore.a \
/usr/local/lib/libcvaux.a /usr/local/lib/libml.a \
/usr/local/lib/libgtk-x11-2.0.a /usr/local/lib/libgdk-x11-2.0.a \
/usr/local/lib/libgobject-2.0.a /usr/local/lib/libglib-2.0.a \
/usr/local/lib/libgthread-2.0.a \
/usr/local/lib/libpng.a /usr/local/lib/libjpeg.a /usr/local/lib/libtiff.a \
/usr/lib/libpthread.a  -Wl,--endgroup

#4


facedect.h:1:16: error: cv.h: No such file or directory
facedect.h:2:21: error: highgui.h: No such file or directory

#5


     不对呀,我的/usr/local/include/opencv 是有cv.h和highgui.h的。
/usr/local/include/opencv # ls
cv.h    cvaux.h    cvcompat.h        cvmat.hpp  cvver.h        cxcore.h    cxerror.h  cxtypes.h  ml.h
cv.hpp  cvaux.hpp  cvhaartraining.h  cvtypes.h  cvvidsurv.hpp  cxcore.hpp  cxmisc.h    highgui.h

#6


是不是因为我同时指定了多个include路径呀?这种写法不正确。
INCLUDEPATH=/usr/local/include/opencv:/usr/local/include/opencvgtk-2.0:/usr/local/include/glib-2.0:/usr/local/include/cairo:/usr/local/include/pango-1.0

#7


有没有大牛指点下哈。。。。搬板凳学习中。。。。