当前位置: 技术问答>linux和unix
如何做到linux下opencv程序的静态编译
来源: 互联网 发布时间:2017-01-15
本文导语: 第一,程序是没有问题的,用的是官方网站的人脸检测的源代码,使用编译命令 g++ `pkg-config opencv --libs --cflags opencv` facedect.cpp -o facedect编译出来的可执行文件,是可以检测出人脸区域的。 第二.我想...
第一,程序是没有问题的,用的是官方网站的人脸检测的源代码,使用编译命令
g++ `pkg-config opencv --libs --cflags opencv` facedect.cpp -o facedect编译出来的可执行文件,是可以检测出人脸区域的。
第二.我想把静态编译该程序,使用了以下编译命令
g++ -I/usr/local/include/opencv -L/usr/local/lib:/usr/lib:/lib facedect.cpp -o facedect /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/lib/libgio-2.0.a
结果出了一堆错误:
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvOnKeyPress':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1085: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1085: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1093: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1094: undefined reference to `g_thread_functions_for_glib_use'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvWaitKey':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1251: undefined reference to `g_timeout_add'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1253: undefined reference to `gtk_main_iteration_do'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1257: undefined reference to `g_source_remove'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1224: undefined reference to `g_thread_self'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1231: undefined reference to `g_get_current_time'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1232: undefined reference to `g_time_val_add'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1233: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1240: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1236: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1233: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1236: undefined reference to `g_thread_functions_for_glib_use'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvOnTrackbar':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1104: undefined reference to `gtk_range_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1104: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1104: undefined reference to `gtk_range_get_value'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvCalcOptimalWindowSize(CvWindow*, CvSize)':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:735: undefined reference to `gtk_widget_get_toplevel'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:737: undefined reference to `gdk_drawable_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:737: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:737: undefined reference to `gdk_drawable_get_size'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvDeleteWindow':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:672: undefined reference to `gtk_widget_destroy'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:686: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:686: undefined reference to `g_thread_functions_for_glib_use'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvWindowThreadLoop':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:523: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:523: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:526: undefined reference to `gtk_main_iteration_do'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:530: undefined reference to `g_usleep'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvInitSystem':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:486: undefined reference to `gtk_init'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvStartWindowThread':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:497: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:503: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:513: undefined reference to `g_thread_create_full'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:499: undefined reference to `g_thread_init'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_get_type()':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:406: undefined reference to `gtk_widget_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:406: undefined reference to `gtk_type_unique'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvOnMouse':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1137: undefined reference to `g_type_check_instance_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_size_request':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:200: undefined reference to `g_type_check_instance_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_class_init':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:368: undefined reference to `gtk_widget_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:368: undefined reference to `gtk_type_class'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:368: undefined reference to `g_type_check_class_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_destroy':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:349: undefined reference to `g_type_check_instance_is_a'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:349: undefined reference to `g_return_if_fail_warning'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:351: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:356: undefined reference to `gtk_object_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:356: undefined reference to `g_type_check_class_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:357: undefined reference to `g_type_check_class_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_set_size':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:228: undefined reference to `g_type_check_instance_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_size_allocate':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:261: undefined reference to `g_type_check_instance_is_a'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:262: undefined reference to `g_return_if_fail_warning'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:265: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:280: undefined reference to `gtk_object_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:280: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:282: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:291: undefined reference to `gdk_window_move_resize'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:294: undefined reference to `gtk_widget_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:294: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:294: undefined reference to `gtk_widget_queue_resize'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:300: undefined reference to `gdk_window_move_resize'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_expose':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:313: undefined reference to `g_type_check_instance_is_a'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:313: undefined reference to `g_return_if_fail_warning'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:319: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:324: undefined reference to `gdk_window_clear_area'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:338: undefined reference to `gdk_draw_rgb_image'
g++ `pkg-config opencv --libs --cflags opencv` facedect.cpp -o facedect编译出来的可执行文件,是可以检测出人脸区域的。
第二.我想把静态编译该程序,使用了以下编译命令
g++ -I/usr/local/include/opencv -L/usr/local/lib:/usr/lib:/lib facedect.cpp -o facedect /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/lib/libgio-2.0.a
结果出了一堆错误:
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvOnKeyPress':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1085: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1085: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1093: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1094: undefined reference to `g_thread_functions_for_glib_use'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvWaitKey':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1251: undefined reference to `g_timeout_add'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1253: undefined reference to `gtk_main_iteration_do'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1257: undefined reference to `g_source_remove'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1224: undefined reference to `g_thread_self'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1231: undefined reference to `g_get_current_time'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1232: undefined reference to `g_time_val_add'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1233: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1240: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1236: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1233: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1236: undefined reference to `g_thread_functions_for_glib_use'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvOnTrackbar':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1104: undefined reference to `gtk_range_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1104: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1104: undefined reference to `gtk_range_get_value'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvCalcOptimalWindowSize(CvWindow*, CvSize)':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:735: undefined reference to `gtk_widget_get_toplevel'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:737: undefined reference to `gdk_drawable_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:737: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:737: undefined reference to `gdk_drawable_get_size'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvDeleteWindow':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:672: undefined reference to `gtk_widget_destroy'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:686: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:686: undefined reference to `g_thread_functions_for_glib_use'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvWindowThreadLoop':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:523: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:523: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:526: undefined reference to `gtk_main_iteration_do'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:530: undefined reference to `g_usleep'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvInitSystem':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:486: undefined reference to `gtk_init'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvStartWindowThread':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:497: undefined reference to `g_threads_got_initialized'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:503: undefined reference to `g_thread_functions_for_glib_use'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:513: undefined reference to `g_thread_create_full'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:499: undefined reference to `g_thread_init'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_get_type()':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:406: undefined reference to `gtk_widget_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:406: undefined reference to `gtk_type_unique'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `icvOnMouse':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:1137: undefined reference to `g_type_check_instance_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_size_request':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:200: undefined reference to `g_type_check_instance_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_class_init':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:368: undefined reference to `gtk_widget_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:368: undefined reference to `gtk_type_class'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:368: undefined reference to `g_type_check_class_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_destroy':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:349: undefined reference to `g_type_check_instance_is_a'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:349: undefined reference to `g_return_if_fail_warning'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:351: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:356: undefined reference to `gtk_object_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:356: undefined reference to `g_type_check_class_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:357: undefined reference to `g_type_check_class_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_set_size':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:228: undefined reference to `g_type_check_instance_cast'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_size_allocate':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:261: undefined reference to `g_type_check_instance_is_a'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:262: undefined reference to `g_return_if_fail_warning'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:265: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:280: undefined reference to `gtk_object_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:280: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:282: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:291: undefined reference to `gdk_window_move_resize'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:294: undefined reference to `gtk_widget_get_type'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:294: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:294: undefined reference to `gtk_widget_queue_resize'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:300: undefined reference to `gdk_window_move_resize'
/usr/local/lib/libhighgui.a(window_gtk.o): In function `cvImageWidget_expose':
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:313: undefined reference to `g_type_check_instance_is_a'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:313: undefined reference to `g_return_if_fail_warning'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:319: undefined reference to `g_type_check_instance_cast'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:324: undefined reference to `gdk_window_clear_area'
/home/apple/tools/opencv-1.0.0/otherlibs/highgui/window_gtk.cpp:338: undefined reference to `gdk_draw_rgb_image'
|
g++ `pkg-config opencv --libs --cflags opencv` facedect.cpp -o facedect -static
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。