hybridgroup / gocv

Go package for computer vision using OpenCV 4 and beyond. Includes support for DNN, CUDA, OpenCV Contrib, and OpenVINO.
https://gocv.io
Other
6.74k stars 868 forks source link

building a static binary Lost Quirc #1179

Open shixiawuheng opened 5 months ago

shixiawuheng commented 5 months ago

command-line-arguments

C:\go\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1 C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lquirc collect2.exe: error: ld returned 1 exit status

While attempting static compilation, I encountered an error and don't understand why Quirc is required.

shixiawuheng commented 5 months ago

I even tried to compile in the gocv/opencv: 4.10.0 static Docker image, but it didn't work

command-line-arguments

/usr/local/go/pkg/tool/linux_amd64/link: running g++ failed: exit status 1 /usr/bin/ld: cannot find -lquirc collect2: error: ld returned 1 exit status

shixiawuheng commented 5 months ago

It was introduced in cgo_static.go, not the library introduced in my project

shixiawuheng commented 5 months ago

I don't understand why others haven't experienced this situation

shixiawuheng commented 5 months ago

After completing the Quirc compilation /usr/bin/ld: /usr/local/lib/libopencv_highgui.a(window_gtk.cpp.o): in function cvImageWidget_class_init(void*, void*)': window_gtk.cpp:(.text._ZL24cvImageWidget_class_initPvS_+0xa): undefined reference togtk_widget_get_type' /usr/bin/ld: window_gtk.cpp:(.text._ZL24cvImageWidget_classinitPvS+0x15): undefined reference to g_type_class_peek' /usr/bin/ld: window_gtk.cpp:(.text._ZL24cvImageWidget_class_initPvS_+0x20): undefined reference tog_type_check_class_cast' /usr/bin/ld: /usr/local/lib/libopencv_highgui.a(window_gtk.cpp.o): in function icvOnTrackbar(_GtkWidget*, void*)': window_gtk.cpp:(.text._ZL13icvOnTrackbarP10_GtkWidgetPv+0xd): undefined reference togtk_range_get_type' /usr/bin/ld: window_gtk.cpp:(.text._ZL13icvOnTrackbarP10_GtkWidgetPv+0x18): undefined reference to g_type_check_instance_cast' /usr/bin/ld: window_gtk.cpp:(.text._ZL13icvOnTrackbarP10_GtkWidgetPv+0x20): undefined reference togtk_range_get_value' /usr/bin/ld: /usr/local/lib/libopencv_highgui.a(window_gtk.cpp.o): in function icvWindowThreadLoop(void*)': window_gtk.cpp:(.text._ZL19icvWindowThreadLoopPv+0x1b): undefined reference togtk_main_iteration_do' /usr/bin/ld: window_gtk.cpp:(.text._ZL19icvWindowThreadLoopPv+0x2d): undefined reference to g_usleep' /usr/bin/ld: window_gtk.cpp:(.text._ZL19icvWindowThreadLoopPv+0x32): undefined reference tog_thread_yield' /usr/bin/ld: window_gtk.cpp:(.text._ZL19icvWindowThreadLoopPv+0x63): undefined reference to gtk_main_iteration_do' /usr/bin/ld: window_gtk.cpp:(.text._ZL19icvWindowThreadLoopPv+0x6d): undefined reference tog_usleep' /usr/bin/ld: window_gtk.cpp:(.text._ZL19icvWindowThreadLoopPv+0x72): undefined reference to g_thread_yield' /usr/bin/ld: /usr/local/lib/libopencv_highgui.a(window_gtk.cpp.o): in functioncvImageWidgetSetImage(_CvImageWidget, void const)': window_gtk.cpp:(.text._ZL21cvImageWidgetSetImageP14_CvImageWidgetPKv+0x11d): undefined reference to `gtk_widget_get_type'

shixiawuheng commented 5 months ago

Why do I still have dynamic library links after going through countless hardships and finally compiling them linux-vdso.so.1 (0x00007ffed1bf2000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x0000745ece701000) libjpeg.so.8 => /lib/x86_64-linux-gnu/libjpeg.so.8 (0x0000745ece67e000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x0000745ece400000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000745ece317000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x0000745ece2ea000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000745ece000000) /lib64/ld-linux-x86-64.so.2 (0x0000745ece72d000)

shixiawuheng commented 5 months ago

Why do I still have dynamic library links after going through countless hardships and finally compiling them linux-vdso.so.1 (0x00007ffed1bf2000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x0000745ece701000) libjpeg.so.8 => /lib/x86_64-linux-gnu/libjpeg.so.8 (0x0000745ece67e000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x0000745ece400000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000745ece317000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x0000745ece2ea000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000745ece000000) /lib64/ld-linux-x86-64.so.2 (0x0000745ece72d000)

olbb commented 3 months ago

Try adding the CMake option -DWITH_QUIRC=ON when building OpenCV

shixiawuheng commented 3 months ago

I am using the official Docker image for compilation. I am not familiar with C++myself, and I cannot even cross compile from Windows to Linux. I am truly ashamed

olbb commented 3 months ago

quirc is used in gocv, but it is disabled in the default rules of opencv, so you need to enable it manually by "-DWITH_QUIRC=ON"

shixiawuheng commented 3 months ago

我感觉我们都是中国人,可以讲中文吗?英语不太好,我是需要在这边下载的脚本中去修改他的CMake标志就可以了是吧 linux-vdso.so.1 (0x00007ffed1bf2000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x0000745ece701000) libjpeg.so.8 => /lib/x86_64-linux-gnu/libjpeg.so.8 (0x0000745ece67e000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x0000745ece400000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000745ece317000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x0000745ece2ea000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000745ece000000) /lib64/ld-linux-x86-64.so.2 (0x0000745ece72d000) 这些库应该也是opencv链接的吧我通过DWITH_QUIRC=ON” 启用了 应该就一起解决了吧

shixiawuheng commented 3 months ago

我有时间去研究一下,但是我感觉我需要先研究怎么在Windows环境交叉编译,非常感谢