gocv
gocv copied to clipboard
golang build static binary with gocv
Description
I want to build a golang program static linked with gocv, which used
go build -a -ldflags '-extldflags "-static"' *.go
but it show below
command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running g++ failed: exit status 1 /usr/bin/ld: cannot find -lopencv_core /usr/bin/ld: cannot find -lopencv_face /usr/bin/ld: cannot find -lopencv_videoio /usr/bin/ld: cannot find -lopencv_imgproc /usr/bin/ld: cannot find -lopencv_highgui /usr/bin/ld: cannot find -lopencv_imgcodecs /usr/bin/ld: cannot find -lopencv_objdetect /usr/bin/ld: cannot find -lopencv_features2d /usr/bin/ld: cannot find -lopencv_video /usr/bin/ld: cannot find -lopencv_dnn /usr/bin/ld: cannot find -lopencv_xfeatures2d /usr/bin/ld: cannot find -lopencv_gapi /usr/bin/ld: cannot find -lopencv_stitching /usr/bin/ld: cannot find -lopencv_aruco /usr/bin/ld: cannot find -lopencv_bgsegm /usr/bin/ld: cannot find -lopencv_bioinspired /usr/bin/ld: cannot find -lopencv_ccalib /usr/bin/ld: cannot find -lopencv_dnn_objdetect /usr/bin/ld: cannot find -lopencv_dnn_superres /usr/bin/ld: cannot find -lopencv_dpm /usr/bin/ld: cannot find -lopencv_highgui /usr/bin/ld: cannot find -lopencv_face /usr/bin/ld: cannot find -lopencv_freetype /usr/bin/ld: cannot find -lopencv_fuzzy /usr/bin/ld: cannot find -lopencv_hdf /usr/bin/ld: cannot find -lopencv_hfs /usr/bin/ld: cannot find -lopencv_img_hash /usr/bin/ld: cannot find -lopencv_line_descriptor /usr/bin/ld: cannot find -lopencv_quality /usr/bin/ld: cannot find -lopencv_reg /usr/bin/ld: cannot find -lopencv_rgbd /usr/bin/ld: cannot find -lopencv_saliency /usr/bin/ld: cannot find -lopencv_stereo /usr/bin/ld: cannot find -lopencv_structured_light /usr/bin/ld: cannot find -lopencv_phase_unwrapping /usr/bin/ld: cannot find -lopencv_superres /usr/bin/ld: cannot find -lopencv_optflow /usr/bin/ld: cannot find -lopencv_surface_matching /usr/bin/ld: cannot find -lopencv_tracking /usr/bin/ld: cannot find -lopencv_datasets /usr/bin/ld: cannot find -lopencv_text /usr/bin/ld: cannot find -lopencv_dnn /usr/bin/ld: cannot find -lopencv_plot /usr/bin/ld: cannot find -lopencv_videostab /usr/bin/ld: cannot find -lopencv_videoio /usr/bin/ld: cannot find -lopencv_xfeatures2d /usr/bin/ld: cannot find -lopencv_shape /usr/bin/ld: cannot find -lopencv_ml /usr/bin/ld: cannot find -lopencv_ximgproc /usr/bin/ld: cannot find -lopencv_video /usr/bin/ld: cannot find -lopencv_xobjdetect /usr/bin/ld: cannot find -lopencv_objdetect /usr/bin/ld: cannot find -lopencv_calib3d /usr/bin/ld: cannot find -lopencv_imgcodecs /usr/bin/ld: cannot find -lopencv_features2d /usr/bin/ld: cannot find -lopencv_flann /usr/bin/ld: cannot find -lopencv_xphoto /usr/bin/ld: cannot find -lopencv_photo /usr/bin/ld: cannot find -lopencv_imgproc /usr/bin/ld: cannot find -lopencv_core /usr/bin/ld: cannot find -lopencv_core /usr/bin/ld: cannot find -lopencv_face /usr/bin/ld: cannot find -lopencv_videoio /usr/bin/ld: cannot find -lopencv_imgproc /usr/bin/ld: cannot find -lopencv_highgui /usr/bin/ld: cannot find -lopencv_imgcodecs /usr/bin/ld: cannot find -lopencv_objdetect /usr/bin/ld: cannot find -lopencv_features2d /usr/bin/ld: cannot find -lopencv_video /usr/bin/ld: cannot find -lopencv_dnn /usr/bin/ld: cannot find -lopencv_xfeatures2d /usr/bin/ld: cannot find -lopencv_core /usr/bin/ld: cannot find -lopencv_face /usr/bin/ld: cannot find -lopencv_videoio /usr/bin/ld: cannot find -lopencv_imgproc /usr/bin/ld: cannot find -lopencv_highgui /usr/bin/ld: cannot find -lopencv_imgcodecs /usr/bin/ld: cannot find -lopencv_objdetect /usr/bin/ld: cannot find -lopencv_features2d /usr/bin/ld: cannot find -lopencv_video /usr/bin/ld: cannot find -lopencv_dnn /usr/bin/ld: cannot find -lopencv_xfeatures2d collect2: error: ld returned 1 exit status
How can I fixed it?
If I just build without static, it can run. But I want to put it on other computer without opencv, thks
Your Environment
- Operating System and version: Ubuntu 18.04.3
- OpenCV version used: 4.2.0
- How did you install OpenCV? golang quick install
- GoCV version used: 0.22.0
- Go version: o1.13.5 linux/amd64
- Did you run the
env.sh
orenv.cmd
script before trying togo run
orgo build
? No
First, you need build opencv library static (Cmake -D BUILD_SHARED_LIBS:=OFF)
I successfully static builded go+opencv+openvino,+dlib,+ffmpeg Not only with tensorflow(
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CUDA_ARCH_BIN=5.3,6.0,6.1,7.0,7.5 \
-D CUDA_ARCH_PTX=5.3 \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.2.0/modules \
-D InferenceEngine_DIR=../dldt/inference-engine/build \
-D WITH_JASPER=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_EXAMPLES=ON \
-D ENABLE_CXX11=ON \
-D WITH_INF_ENGINE=ON \
-D WITH_QT=OFF \
-D WITH_GTK=ON \
-D WITH_FFMPEG=OFF \
-D WITH_CUDA=ON \
-D WITH_TIFF=OFF \
-D WITH_WEBP=OFF \
-D WITH_QT=OFF \
-D WITH_PNG=OFF \
-D WITH_1394=OFF \
-D HAVE_OPENEXR=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_opencv_java=NO \
-D BUILD_opencv_python=NO \
-D BUILD_opencv_python2=NO \
-D BUILD_opencv_python3=NO \
-D BUILD_SHARED_LIBS=OFF \
-D OPENCV_GENERATE_PKGCONFIG=ON ..
I met the same problem. Now I had compiled static opencv4.2.0 libraries, then I use externel mode to compile golang program which based on gocv. unfortunately, It cannot work find. Error: OpenCV 4.x+ requires enabled C++11 support
Cmd: export CGO_CPPFLAGS="-I/usr/local/opencv/include/opencv4" export CGO_LDFLAGS="/usr/local/opencv/lib/libopencv_core.a /usr/local/opencv/lib/libopencv_face.a /usr/local/opencv/lib/libopencv_videoio.a /usr/local/opencv/lib/libopencv_imgproc.a /usr/local/opencv/lib/libopencv_highgui.a /usr/local/opencv/lib/libopencv_imgcodecs.a /usr/local/opencv/lib/libopencv_objdetect.a /usr/local/opencv/lib/libopencv_features2d.a /usr/local/opencv/lib/libopencv_video.a /usr/local/opencv/lib/libopencv_dnn.a /usr/local/opencv/lib/libopencv_xfeatures2d.a" go build -ldflags "-linkmode 'external' -extldflags '-static'" -tags customenv
@cnjeffliu , please attach log with errors
Maybe
/usr/local/opencv/lib/libopencv_core.a
need be
/usr/local/lib/libopencv_core.a
try
ls /usr/local/opencv/lib/libopencv_core.a
ls /usr/local/lib/libopencv_core.a
CGO_CPPFLAGS "-I/usr/local/include -I/usr/local/include/opencv4"
CGO_LDFLAGS "-I/usr/local/include/opencv4 -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_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_photo -lopencv_imgproc -lopencv_core -littnotify -llibprotobuf -lIlmImf -lquirc -lippiw -lippicv -lade -lz -ljpeg -ldl -lm -lpthread -lrt -lopenblas -lquadmath -linference_engine_s -lpugixml -lngraph -lgfortran -ltbb"
go build --ldflags '-extldflags "-static"' -o programm .
Works for me in docker (with openvino)
@Danile71 I specified the installed path on /usr/local/opencv when compiled the opencv .
@cnjeffliu , CGO_LDFLAGS="-L/usr/local/opencv/lib/ -lopencv_core.a...
@Danile71 I get the error like 'OpenCV 4.x+ requires enabled C++11 support' as before when compiled the program which based on gocv .
@Danile71 In win 10。 build opencv library static。after go run I get too many errors like this
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvRQDecomp3x3+0x1fe): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvRQDecomp3x3+0x6c2): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvRQDecomp3x3+0x6da): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvRQDecomp3x3+0x6f2): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvRQDecomp3x3+0x715): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvRQDecomp3x3+0x738): more undefined references to `cvConvertScale' follow
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0xaa0): undefined reference to `cvAvg'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x103f): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x1076): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x10b6): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x125c): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x1274): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x168f): undefined reference to `cvNorm'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x170d): undefined reference to `cvNorm'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x172b): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x17e0): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvFindExtrinsicCameraParams2+0x1801): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$cvInitIntrinsicParams2D+0x86d): undefined reference to `cvConvertScale'
C:/opencv/build-static/install/x64/mingw/staticlib/libopencv_calib3d420.a(calibration.cpp.obj):calibration.cpp:(.text$_ZL26cvCalibrateCamera2InternalPK5CvMatS1_S1_6CvSizeiPS_S3_S3_S3_S3_S3_S3_i14CvTermCriteria+0x4efb): undefined reference to `cvConvertScale'
I had the same issue as at the first message. Then I used the advice of @Danile71 by and ran next commands:
cd ~/go/src/gocv.io/x/gocv
make download
cd /tmp/opencv/opencv-4.2.0/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_ARCH_BIN=5.3,6.0,6.1,7.0,7.5 -D CUDA_ARCH_PTX=5.3 -D OPENCV_EXTRA_MODULES_PATH=/tmp/opencv/opencv_contrib-4.2.0/modules -D InferenceEngine_DIR=../dldt/inference-engine/build -D WITH_JASPER=OFF -D BUILD_DOCS=OFF -D BUILD_EXAMPLES=ON -D ENABLE_CXX11=ON -D WITH_INF_ENGINE=ON -D WITH_QT=OFF -D WITH_GTK=ON -D WITH_FFMPEG=OFF -D WITH_CUDA=ON -D WITH_TIFF=OFF -D WITH_WEBP=OFF -D WITH_QT=OFF -D WITH_PNG=OFF -D WITH_1394=OFF -D HAVE_OPENEXR=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_opencv_java=NO -D BUILD_opencv_python=NO -D BUILD_opencv_python2=NO -D BUILD_opencv_python3=NO -D BUILD_SHARED_LIBS=OFF -D OPENCV_GENERATE_PKGCONFIG=ON ..
make -j $(shell nproc --all)
make preinstall
sudo make install
sudo ldconfig
I tried to build my app again and it gave me an error with different output. I am not sure that I did everything right. @Danile71 could you advise me? here is my build log and Makefile I used
Does anyone have a working solution for this
I don't have the cmake gui
I use ldd main(the executable file) to find the shared library of the executable file, then find the corresponding static library and link them. Could I solve it?
Does anyone have a working solution for this
I don't have the cmake gui
Did you solve the problem?
@meilin-shi no that's why im asking
I met the same problem with gocv v0.25.0, I just can't build a static binary with gocv :( Am I missing something?
I met the same problem with gocv v0.25.0, I just can't build a static binary with gocv :( Am I missing something?
what is the message it prompt? If you add all the library of opencv ,you'll build it successful
I am also struggling to achieve a static build
any news? that would be a really nice feature to statically build on windows, but I also get errors.
This is a new PR to address the static build issue on Linux: https://github.com/hybridgroup/gocv/pull/802
Windows will be worked on in a subsequent PR.
Has the work already started for a static build on windows?
I tested it today on Ubuntu Linux 20.04 LTS and it works perfectly throughout all the installation and compilation process.
But after building with:
go build -tags static --ldflags '-extldflags "-static"'
It gives me the following runtime errors:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.3) /tmp/opencv/opencv-4.5.3/modules/imgproc/src/smooth.dispatch.cpp:617: error: (-215:Assertion failed) !_src.empty() in function 'GaussianBlur'
SIGABRT: abort
PC=0x2c52edb m=0 sigcode=18446744073709551610
goroutine 0 [idle]:
runtime: unknown pc 0x2c52edb
stack: frame={sp:0x7ffe0cd543e0, fp:0x0} stack=[0x7ffe0c555d68,0x7ffe0cd54da0)
0x00007ffe0cd542e0: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd542f0: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd54300: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd54310: 0xfffffffffffffff8 0x0000000000000001
0x00007ffe0cd54320: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd54330: 0x0000000000000000 0x0000000000000030
0x00007ffe0cd54340: 0x0000000000000007 0x0000000000000000
0x00007ffe0cd54350: 0x0000000000000001 0x0000000000493988
0x00007ffe0cd54360: 0x0000000002b3cc40 0xfffffffffffffff8
0x00007ffe0cd54370: 0x0000000000000001 0x0000000000000010
0x00007ffe0cd54380: 0x0000000000011b1b 0x0000000000000000
0x00007ffe0cd54390: 0x4000000000000000 0x0000000003e64360
0x00007ffe0cd543a0: 0x0000000000000001 0x0000000003738548
0x00007ffe0cd543b0: 0x0000000003e42a80 0x00000000010f5840
0x00007ffe0cd543c0: 0x0000000003e643e0 0x00007ffe0cd546d0
0x00007ffe0cd543d0: 0x0000000002ec83d0 0x00000000004939f1
0x00007ffe0cd543e0: <0x0000000000000000 0x0000000f00000002
0x00007ffe0cd543f0: 0x00007ffe0cd540d8 0x0000000000000000
0x00007ffe0cd54400: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd54410: 0x656378453a3a7663 0x0000006e6f697470
0x00007ffe0cd54420: 0x00007ffe0cd54c90 0x00007ffe0cd54c98
0x00007ffe0cd54430: 0x00007ffe0cd54ca0 0x00007ffe0cd54ca8
0x00007ffe0cd54440: 0x00007ffe0cd54d18 0x0000000000000000
0x00007ffe0cd54450: 0x00007ffe0cd54d20 0x00000000004f7930 <runtime.asmcgocall+0x0000000000000070>
0x00007ffe0cd54460: 0xfffffffe7fffffff 0xffffffffffffffff
0x00007ffe0cd54470: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd54480: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd54490: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd544a0: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd544b0: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd544c0: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd544d0: 0xffffffffffffffff 0xffffffffffffffff
runtime: unknown pc 0x2c52edb
stack: frame={sp:0x7ffe0cd543e0, fp:0x0} stack=[0x7ffe0c555d68,0x7ffe0cd54da0)
0x00007ffe0cd542e0: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd542f0: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd54300: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd54310: 0xfffffffffffffff8 0x0000000000000001
0x00007ffe0cd54320: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd54330: 0x0000000000000000 0x0000000000000030
0x00007ffe0cd54340: 0x0000000000000007 0x0000000000000000
0x00007ffe0cd54350: 0x0000000000000001 0x0000000000493988
0x00007ffe0cd54360: 0x0000000002b3cc40 0xfffffffffffffff8
0x00007ffe0cd54370: 0x0000000000000001 0x0000000000000010
0x00007ffe0cd54380: 0x0000000000011b1b 0x0000000000000000
0x00007ffe0cd54390: 0x4000000000000000 0x0000000003e64360
0x00007ffe0cd543a0: 0x0000000000000001 0x0000000003738548
0x00007ffe0cd543b0: 0x0000000003e42a80 0x00000000010f5840
0x00007ffe0cd543c0: 0x0000000003e643e0 0x00007ffe0cd546d0
0x00007ffe0cd543d0: 0x0000000002ec83d0 0x00000000004939f1
0x00007ffe0cd543e0: <0x0000000000000000 0x0000000f00000002
0x00007ffe0cd543f0: 0x00007ffe0cd540d8 0x0000000000000000
0x00007ffe0cd54400: 0x0000000000000000 0x0000000000000000
0x00007ffe0cd54410: 0x656378453a3a7663 0x0000006e6f697470
0x00007ffe0cd54420: 0x00007ffe0cd54c90 0x00007ffe0cd54c98
0x00007ffe0cd54430: 0x00007ffe0cd54ca0 0x00007ffe0cd54ca8
0x00007ffe0cd54440: 0x00007ffe0cd54d18 0x0000000000000000
0x00007ffe0cd54450: 0x00007ffe0cd54d20 0x00000000004f7930 <runtime.asmcgocall+0x0000000000000070>
0x00007ffe0cd54460: 0xfffffffe7fffffff 0xffffffffffffffff
0x00007ffe0cd54470: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd54480: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd54490: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd544a0: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd544b0: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd544c0: 0xffffffffffffffff 0xffffffffffffffff
0x00007ffe0cd544d0: 0xffffffffffffffff 0xffffffffffffffff
goroutine 1 [syscall]:
runtime.cgocall(0x524df0, 0xc000054da8)
/usr/local/go/src/runtime/cgocall.go:156 +0x5c fp=0xc000054d78 sp=0xc000054d40 pc=0x49f33c
gocv.io/x/gocv._Cfunc_GaussianBlur(0x3e5ebf0, 0x3e5ebf0, {0x7, 0x7}, 0x0, 0x0, 0x4)
_cgo_gotypes.go:2055 +0x45 fp=0xc000054da8 sp=0xc000054d78 pc=0x51da25
gocv.io/x/gocv.GaussianBlur.func1({0x3e5ebf0, {0x0, 0xc000054e68, 0x0}}, 0x2d15e80, {0x374b380, 0x0}, 0x0, 0x0, 0x4)
/home/danort/go/pkg/mod/gocv.io/x/[email protected]/imgproc.go:874 +0xcd fp=0xc000054e00 sp=0xc000054da8 pc=0x51fd2d
gocv.io/x/gocv.GaussianBlur({0x3e5ebf0, {0x0, 0x3e5ebf0, 0x3e42160}}, 0x0, {0x0, 0x3e5ebf0}, 0xc000054ea8, 0x51e6b9, 0xc0000a0340)
/home/danort/go/pkg/mod/gocv.io/x/[email protected]/imgproc.go:874 +0x25 fp=0xc000054e58 sp=0xc000054e00 pc=0x51fbc5
main.blurAndBinarize({0x3e5ebf0, {0x0, 0x4d2dae, 0xc0000001a0}}, {0x3e5ebf0, {0x0, 0x0, 0x0}}, 0xc000046738, 0x5, ...)
/home/danort/Documents/vscodeprojects/golang/goOpenCV/main.go:57 +0x65 fp=0xc000054eb8 sp=0xc000054e58 pc=0x5207a5
main.main()
/home/danort/Documents/vscodeprojects/golang/goOpenCV/main.go:33 +0x191 fp=0xc000054f80 sp=0xc000054eb8 pc=0x520571
runtime.main()
/usr/local/go/src/runtime/proc.go:255 +0x227 fp=0xc000054fe0 sp=0xc000054f80 pc=0x4cefc7
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000054fe8 sp=0xc000054fe0 pc=0x4f7c41
rax 0x0
rbx 0x3e3f380
rcx 0x2c52edb
rdx 0x0
rdi 0x2
rsi 0x7ffe0cd543e0
rbp 0x3e62af0
rsp 0x7ffe0cd543e0
r8 0x0
r9 0x7ffe0cd543e0
r10 0x8
r11 0x246
r12 0x3e42a80
r13 0x10f5840
r14 0x3e643e0
r15 0x7ffe0cd546d0
rip 0x2c52edb
rflags 0x246
cs 0x33
fs 0x0
gs 0x0
I'll appreciate much any help to know what could be wrong.
Is there any news on this?
At risk of piling on the "we want to statically compile gocv so we can use anything that uses it standalone on production" - I think the main supported OS/s really need this. Throwing in MacOS here. Thanks for all the hard work on the Windows one! PS - Will check back in 2 years :D
It looks like this is almost working, I got 3 linking errors though.
#9 584.7 go run -tags static ./cmd/version/main.go
#9 613.8 # gocv.io/x/gocv
#9 613.8 /usr/bin/ld: cannot find -lippiw
#9 613.8 /usr/bin/ld: cannot find -lippicv
#9 613.8 /usr/bin/ld: cannot find -lquadmath
#9 613.8 collect2: error: ld returned 1 exit status
#9 613.9 make: *** [Makefile:281: verify_static] Error
I'm trying to build without using libdc1394-devel and gtk2-devel then I'm getting the following error:
command-line-arguments
/usr/lib/golang/pkg/tool/linux_amd64/link: running g++ failed: exit status 1 /usr/bin/ld: cannot find -littnotify: No such file or directory /usr/bin/ld: cannot find -llibprotobuf: No such file or directory /usr/bin/ld: cannot find -lIlmImf: No such file or directory /usr/bin/ld: cannot find -lquirc: No such file or directory /usr/bin/ld: cannot find -lippiw: No such file or directory /usr/bin/ld: cannot find -lippicv: No such file or directory /usr/bin/ld: cannot find -lade: No such file or directory /usr/bin/ld: cannot find -lquadmath: No such file or directory collect2: error: ld returned 1 exit status
using amazon linux image. Maybe those 2 missing packages could produce those errors?
I know this is only ~1.5 years later, but can this be used standalone yet?
So after some testing around i succeded in building a single binary file in windows . Consider adding it to the documentation if needed.
first as before you need to build a static opencv lib. for me in windows its as simple as using the provided batch script win_build_opencv.cmd
calling it from a terminal and adding static
as an argument
win_build_opencv.cmd static
when building your go excutable simply use the following command
go build -tags static -ldflags="-extldflags=-static" main.go
you can add a -x to see the output . This will result in a single excutable file that is staticly built in windows. I have not test it in linux but i assume the same principle applies there
So after some testing around i succeded in building a single binary file in windows . Consider adding it to the documentation if needed.
Great to hear, and thanks so much for the info @ajmandourah! I have been thinking to try this again soon (on Linux primarily, but also Windows). Will make sure to report any progress.
Any progress for linux?