From 9dab401668f14d255045be2037c4de47cf15491d Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 21 Sep 2024 09:15:14 +0200 Subject: [PATCH 1/4] cgo: add options for linux arm64 and separate darwin builds Signed-off-by: deadprogram --- cgo_static.go | 8 ++++---- cgo_static_darwin.go | 11 +++++++++++ contrib/cgo_static.go | 8 ++++---- contrib/cgo_static_darwin.go | 11 +++++++++++ cuda/cgo_static.go | 8 ++++---- cuda/cgo_static_darwin.go | 11 +++++++++++ 6 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 cgo_static_darwin.go create mode 100644 contrib/cgo_static_darwin.go create mode 100644 cuda/cgo_static_darwin.go diff --git a/cgo_static.go b/cgo_static.go index c32d74cc..45d070e2 100644 --- a/cgo_static.go +++ b/cgo_static.go @@ -1,13 +1,13 @@ -//go:build !customenv && static && !windows +//go:build !customenv && static && linux package gocv // Changes here should be mirrored in contrib/cgo_static.go and cuda/cgo_static.go. /* -#cgo CXXFLAGS: --std=c++11 +#cgo CXXFLAGS: --std=c++11 #cgo CPPFLAGS: -I/usr/local/include -I/usr/local/include/opencv4 -#cgo amd64 LDFLAGS: -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -L/usr/lib/x86_64-linux-gnu -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_highgui -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_wechat_qrcode -lopencv_photo -lopencv_imgproc -lopencv_core -littnotify -llibprotobuf -lIlmImf -lquirc -lippiw -lippicv -lade -lz -ldl -lm -lpthread -lrt -lquadmath -ltbb -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lpng -llibwebp -llibtiff -llibopenjp2 -llibjpeg-turbo -#cgo arm64 LDFLAGS: -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -L/usr/lib/x86_64-linux-gnu -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_highgui -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_wechat_qrcode -lopencv_photo -lopencv_imgproc -lopencv_core -littnotify -llibprotobuf -lIlmImf -lquirc -lade -lz -ldl -lm -lpthread -lrt -ltbb -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lpng -llibwebp -llibtiff -llibopenjp2 -llibjpeg-turbo -ltegra_hal +#cgo amd64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -lippiw -lippicv -lpng -lz -lfreetype -lharfbuzz -ldl -lm -lpthread +#cgo arm64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -ltegra_hal -lpng -lz -lfreetype -lharfbuzz -lIconv::Iconv -ldl -lm -lpthread -lrt */ import "C" diff --git a/cgo_static_darwin.go b/cgo_static_darwin.go new file mode 100644 index 00000000..d7166115 --- /dev/null +++ b/cgo_static_darwin.go @@ -0,0 +1,11 @@ +//go:build !customenv && static && darwin + +package gocv + +// Changes here should be mirrored in contrib/cgo_static_darwin.go and cuda/cgo_static_darwin.go. + +/* +#cgo CXXFLAGS: --std=c++11 +#cgo pkg-config: --static opencv4 +*/ +import "C" diff --git a/contrib/cgo_static.go b/contrib/cgo_static.go index c32d74cc..23161d63 100644 --- a/contrib/cgo_static.go +++ b/contrib/cgo_static.go @@ -1,13 +1,13 @@ -//go:build !customenv && static && !windows +//go:build !customenv && static && linux package gocv // Changes here should be mirrored in contrib/cgo_static.go and cuda/cgo_static.go. /* -#cgo CXXFLAGS: --std=c++11 +#cgo CXXFLAGS: --std=c++11 #cgo CPPFLAGS: -I/usr/local/include -I/usr/local/include/opencv4 -#cgo amd64 LDFLAGS: -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -L/usr/lib/x86_64-linux-gnu -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_highgui -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_wechat_qrcode -lopencv_photo -lopencv_imgproc -lopencv_core -littnotify -llibprotobuf -lIlmImf -lquirc -lippiw -lippicv -lade -lz -ldl -lm -lpthread -lrt -lquadmath -ltbb -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lpng -llibwebp -llibtiff -llibopenjp2 -llibjpeg-turbo -#cgo arm64 LDFLAGS: -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -L/usr/lib/x86_64-linux-gnu -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_highgui -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_wechat_qrcode -lopencv_photo -lopencv_imgproc -lopencv_core -littnotify -llibprotobuf -lIlmImf -lquirc -lade -lz -ldl -lm -lpthread -lrt -ltbb -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lpng -llibwebp -llibtiff -llibopenjp2 -llibjpeg-turbo -ltegra_hal +#cgo amd64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -lippiw -lippicv -lpng -lz -lfreetype -lharfbuzz -ldl -lm -lpthread -lrt +#cgo arm64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -ltegra_hal -lpng -lz -lfreetype -lharfbuzz -ldl -lm -lpthread -lrt */ import "C" diff --git a/contrib/cgo_static_darwin.go b/contrib/cgo_static_darwin.go new file mode 100644 index 00000000..d7166115 --- /dev/null +++ b/contrib/cgo_static_darwin.go @@ -0,0 +1,11 @@ +//go:build !customenv && static && darwin + +package gocv + +// Changes here should be mirrored in contrib/cgo_static_darwin.go and cuda/cgo_static_darwin.go. + +/* +#cgo CXXFLAGS: --std=c++11 +#cgo pkg-config: --static opencv4 +*/ +import "C" diff --git a/cuda/cgo_static.go b/cuda/cgo_static.go index c32d74cc..45d070e2 100644 --- a/cuda/cgo_static.go +++ b/cuda/cgo_static.go @@ -1,13 +1,13 @@ -//go:build !customenv && static && !windows +//go:build !customenv && static && linux package gocv // Changes here should be mirrored in contrib/cgo_static.go and cuda/cgo_static.go. /* -#cgo CXXFLAGS: --std=c++11 +#cgo CXXFLAGS: --std=c++11 #cgo CPPFLAGS: -I/usr/local/include -I/usr/local/include/opencv4 -#cgo amd64 LDFLAGS: -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -L/usr/lib/x86_64-linux-gnu -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_highgui -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_wechat_qrcode -lopencv_photo -lopencv_imgproc -lopencv_core -littnotify -llibprotobuf -lIlmImf -lquirc -lippiw -lippicv -lade -lz -ldl -lm -lpthread -lrt -lquadmath -ltbb -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lpng -llibwebp -llibtiff -llibopenjp2 -llibjpeg-turbo -#cgo arm64 LDFLAGS: -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -L/usr/lib/x86_64-linux-gnu -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_highgui -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_wechat_qrcode -lopencv_photo -lopencv_imgproc -lopencv_core -littnotify -llibprotobuf -lIlmImf -lquirc -lade -lz -ldl -lm -lpthread -lrt -ltbb -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lpng -llibwebp -llibtiff -llibopenjp2 -llibjpeg-turbo -ltegra_hal +#cgo amd64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -lippiw -lippicv -lpng -lz -lfreetype -lharfbuzz -ldl -lm -lpthread +#cgo arm64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -ltegra_hal -lpng -lz -lfreetype -lharfbuzz -lIconv::Iconv -ldl -lm -lpthread -lrt */ import "C" diff --git a/cuda/cgo_static_darwin.go b/cuda/cgo_static_darwin.go new file mode 100644 index 00000000..d7166115 --- /dev/null +++ b/cuda/cgo_static_darwin.go @@ -0,0 +1,11 @@ +//go:build !customenv && static && darwin + +package gocv + +// Changes here should be mirrored in contrib/cgo_static_darwin.go and cuda/cgo_static_darwin.go. + +/* +#cgo CXXFLAGS: --std=c++11 +#cgo pkg-config: --static opencv4 +*/ +import "C" From 83ad8e139bbd2faf73eccf23bab4db528f2c060a Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 21 Sep 2024 18:17:58 +0200 Subject: [PATCH 2/4] docker: downgrade static build to Go 1.22 to avoid https://github.com/golang/go/issues/68976 Signed-off-by: deadprogram --- Dockerfile.opencv-static | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.opencv-static b/Dockerfile.opencv-static index c900b0c8..e150d3d6 100644 --- a/Dockerfile.opencv-static +++ b/Dockerfile.opencv-static @@ -11,7 +11,7 @@ # amd64 build stage ################### -FROM --platform=linux/amd64 golang:1.23-bullseye AS opencv-base-amd64 +FROM --platform=linux/amd64 golang:1.22-bullseye AS opencv-base-amd64 LABEL maintainer="hybridgroup" RUN apt-get update && apt-get install -y \ @@ -87,7 +87,7 @@ RUN cd opencv-${OPENCV_VERSION} && \ # arm64 build stage ################### -FROM --platform=linux/arm64 golang:1.23-bullseye AS opencv-base-arm64 +FROM --platform=linux/arm64 golang:1.22-bullseye AS opencv-base-arm64 LABEL maintainer="hybridgroup" RUN apt-get update && apt-get install -y \ From 56318e0f9599732a742165fd67b5180f6dd0556b Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sun, 22 Sep 2024 10:10:45 +0200 Subject: [PATCH 3/4] cgo: remove unneeded lib from link for linux/arm64 Signed-off-by: deadprogram --- cgo_static.go | 2 +- cuda/cgo_static.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cgo_static.go b/cgo_static.go index 45d070e2..91c9d217 100644 --- a/cgo_static.go +++ b/cgo_static.go @@ -8,6 +8,6 @@ package gocv #cgo CXXFLAGS: --std=c++11 #cgo CPPFLAGS: -I/usr/local/include -I/usr/local/include/opencv4 #cgo amd64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -lippiw -lippicv -lpng -lz -lfreetype -lharfbuzz -ldl -lm -lpthread -#cgo arm64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -ltegra_hal -lpng -lz -lfreetype -lharfbuzz -lIconv::Iconv -ldl -lm -lpthread -lrt +#cgo arm64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -ltegra_hal -lpng -lz -lfreetype -lharfbuzz -ldl -lm -lpthread -lrt */ import "C" diff --git a/cuda/cgo_static.go b/cuda/cgo_static.go index 45d070e2..91c9d217 100644 --- a/cuda/cgo_static.go +++ b/cuda/cgo_static.go @@ -8,6 +8,6 @@ package gocv #cgo CXXFLAGS: --std=c++11 #cgo CPPFLAGS: -I/usr/local/include -I/usr/local/include/opencv4 #cgo amd64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -lippiw -lippicv -lpng -lz -lfreetype -lharfbuzz -ldl -lm -lpthread -#cgo arm64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -ltegra_hal -lpng -lz -lfreetype -lharfbuzz -lIconv::Iconv -ldl -lm -lpthread -lrt +#cgo arm64 LDFLAGS: -O2 -g -static -L/usr/local/lib -L/usr/local/lib/opencv4/3rdparty -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -llibprotobuf -lade -ltbb -littnotify -llibjpeg-turbo -llibwebp -llibtiff -llibopenjp2 -lIlmImf -lquirc -ltegra_hal -lpng -lz -lfreetype -lharfbuzz -ldl -lm -lpthread -lrt */ import "C" From 77e3d8a569399da2d5cc17ecf1a8da6ad7b34ff1 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sun, 22 Sep 2024 10:13:11 +0200 Subject: [PATCH 4/4] docker: updated version for gocv-static-builder image Signed-off-by: deadprogram --- Dockerfile-static-builder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile-static-builder b/Dockerfile-static-builder index 1f6ff582..df21643c 100755 --- a/Dockerfile-static-builder +++ b/Dockerfile-static-builder @@ -1,15 +1,15 @@ # to build this docker image: # docker build -f Dockerfile-static-builder -t gocv-static-builder . # or for multi-arch builds: -# docker buildx build -f Dockerfile-static-builder -t gocv-static-builder --platform=linux/amd64,linux/arm64 . +# docker buildx build -f Dockerfile-static-builder -t ghcr.io/hybridgroup/gocv-static-builder --platform=linux/amd64,linux/arm64 --push . # # to use this docker image: # cd /path/to/my/project -# docker run --rm -e "BINARYNAME=myapp" -e "SRCPATH=./cmd/mycmd" -v $(pwd):/src -v $(pwd)/build:/build -a stdout -a stderr --platform=linux/arm64 gocv-static-builder +# docker run --rm -e "BINARYNAME=mjpeg-streamer" -e "SRCPATH=./cmd/mjpeg-streamer" -v $(pwd):/src -v $(pwd)/build:/build -a stdout -a stderr --platform linux/amd64 gocv-static-builder # # NOTE that you cannot use highgui from the static build! # -FROM ghcr.io/hybridgroup/opencv:4.10.0-static AS gocv-static-builder +FROM --platform=$BUILDPLATFORM ghcr.io/hybridgroup/opencv:4.10.0-static AS gocv-static-builder WORKDIR /src