gocv-alpine icon indicating copy to clipboard operation
gocv-alpine copied to clipboard

Unable to link go app against gocv in container

Open Sauraus opened this issue 5 years ago • 0 comments

Step 7/13 : ENV CGO_LDFLAGS "-L/usr/local/lib64 -lopencv_core -lopencv_face -lopencv_videoio -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_objdetect -lopencv_features2d -lopencv_video -lopencv_dnn -lopencv_xfeatures2d -lopencv_plot -lopencv_tracking" ---> Running in bc1b6ba9cb0b Removing intermediate container bc1b6ba9cb0b ---> 26a9b6248b32 Step 8/13 : RUN cd $GOPATH/src/github.com/EsportsOne/oneview-golang && CGO_ENABLED=1 GOOS=linux packr2 build -a -tags netgo -ldflags '-w -extldflags "-static"' -o oneview . ---> Running in e2fc156622c4 github.com/EsportsOne/oneview-golang /usr/local/go/pkg/tool/linux_amd64/link: running g++ failed: exit status 1 /usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lopencv_core

The above is the error that I get when I try to actually build a static go app that is dependent on gocv, I had to overwrite the CGO_LDFLAGS because the development image defined the folder as being -L/usr/local/lib without the 64 part which is wrong for Alpine.

I can see the opencv_core lib in the /usr/local/lib64 folder and its also listed in the CFO_LDFLAGS and yet the linker barfs on them any idea?

Sauraus avatar Feb 27 '19 22:02 Sauraus