Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build docker image on mac M1 #1181

Open
dnjooiopa opened this issue Jun 26, 2024 · 1 comment
Open

Cannot build docker image on mac M1 #1181

dnjooiopa opened this issue Jun 26, 2024 · 1 comment

Comments

@dnjooiopa
Copy link

Description

I clone repository and try running make docker but got this error.

docker build --build-arg OPENCV_VERSION=4.10.0 --build-arg GOVERSION=1.22.3 .
[+] Building 106.8s (9/9) FINISHED                                                                                                     docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                   0.1s
 => => transferring dockerfile: 252B                                                                                                                   0.0s
 => [internal] load metadata for ghcr.io/hybridgroup/opencv:4.10.0                                                                                     2.7s
 => [auth] hybridgroup/opencv:pull token for ghcr.io                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                        0.0s
 => [internal] load build context                                                                                                                      0.1s
 => => transferring context: 15.06kB                                                                                                                   0.0s
 => [1/4] FROM ghcr.io/hybridgroup/opencv:4.10.0@sha256:22cef7f1027ea868a820e7c71f642150454777c7bd0d401b09acabe750411a2f                               0.0s
 => CACHED [2/4] COPY . /go/src/gocv.io/x/gocv/                                                                                                        0.0s
 => CACHED [3/4] WORKDIR /go/src/gocv.io/x/gocv                                                                                                        0.0s
 => ERROR [4/4] RUN go build -tags example -o /build/gocv_version ./cmd/version/                                                                     103.6s
------                                                                                                                                                      
 > [4/4] RUN go build -tags example -o /build/gocv_version ./cmd/version/:                                                                                  
103.2 # gocv.io/x/gocv/cmd/version                                                                                                                          
103.2 /usr/local/go/pkg/tool/linux_arm64/link: running g++ failed: exit status 1                                                                            
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::spawn(tbb::detail::d1::task&, tbb::detail::d1::task_group_context&)'                                                                                                                                                      
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::allocate(tbb::detail::d1::small_object_pool*&, unsigned long)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::deallocate(tbb::detail::d1::small_object_pool&, void*, unsigned long, tbb::detail::d1::execution_data const&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::initialize(tbb::detail::d1::task_arena_base&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::destroy(tbb::detail::d1::task_group_context&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::allocate(tbb::detail::d1::small_object_pool*&, unsigned long, tbb::detail::d1::execution_data const&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::execute(tbb::detail::d1::task_arena_base&, tbb::detail::d1::delegate_base&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::terminate(tbb::detail::d1::task_arena_base&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::execute_and_wait(tbb::detail::d1::task&, tbb::detail::d1::task_group_context&, tbb::detail::d1::wait_context&, tbb::detail::d1::task_group_context&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::initialize(tbb::detail::d1::task_group_context&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::is_group_execution_cancelled(tbb::detail::d1::task_group_context&)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::execution_slot(tbb::detail::d1::execution_data const*)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::max_concurrency(tbb::detail::d1::task_arena_base const*)'
103.2 /usr/bin/ld: /usr/local/lib/libopencv_core.so: undefined reference to `tbb::detail::r1::notify_waiters(unsigned long)'
103.2 collect2: error: ld returned 1 exit status
103.2 
------
Dockerfile:8
--------------------
   6 |     
   7 |     WORKDIR /go/src/gocv.io/x/gocv
   8 | >>> RUN go build -tags example -o /build/gocv_version ./cmd/version/
   9 |     
  10 |     CMD ["/build/gocv_version"]
--------------------
ERROR: failed to solve: process "/bin/sh -c go build -tags example -o /build/gocv_version ./cmd/version/" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/rpwdonoen92b698bxi1ko25rr
make: *** [docker] Error 1

Steps to Reproduce

  1. Run make docker

Your Environment

  • Operating System and version: macOS Sonoma 14.5
  • OpenCV version used: 4.10.0
  • GOVERSION: 1.22.3
  • Docker image: ghcr.io/hybridgroup/opencv:4.10.0
@egawata
Copy link

egawata commented Sep 1, 2024

I have the same problem on my M3 mac.
I've tried downgrading OpenCV to 4.9.0 by replacing the following line in Dockerfile, and it seems working well.

FROM ghcr.io/hybridgroup/opencv:4.9.0

Maybe something has changed between 4.9.0 and 4.10.0 which makes it impossible to build on arm64.

(update)

Instead of downgrading, adding the following line would also solve.

diff --git a/cgo.go b/cgo.go
index 71dda49..47facdf 100644
--- a/cgo.go
+++ b/cgo.go
@@ -7,6 +7,7 @@ package gocv

 /*
 #cgo !windows pkg-config: opencv4
+#cgo !windows LDFLAGS: -ltbb
 #cgo CXXFLAGS:   --std=c++11
 #cgo windows  CPPFLAGS:   -IC:/opencv/build/install/include
 #cgo windows  LDFLAGS:    -LC:/opencv/build/install/x64/mingw/lib -lopencv_core4100 -lopencv_face4100 -lopencv_videoio4100 -lopencv_imgproc4100 -lopencv_highgui4100 -lopencv_imgcodecs4100 -lopencv_objdetect4100 -lopencv_features2d4100 -lopencv_video4100 -lopencv_dnn4100 -lopencv_xfeatures2d4100 -lopencv_plot4100 -lopencv_tracking4100 -lopencv_img_hash4100 -lopencv_calib3d4100 -lopencv_bgsegm4100 -lopencv_photo4100 -lopencv_aruco4100 -lopencv_wechat_qrcode4100 -lopencv_ximgproc4100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants