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

all: correctly working static builds #1226

Merged
merged 7 commits into from
Sep 19, 2024
Merged

all: correctly working static builds #1226

merged 7 commits into from
Sep 19, 2024

Conversation

deadprogram
Copy link
Member

This PR modifies the static build capability for GoCV to correctly work to build fully statically linked binaries for Linux.

To build the static binary:

docker build -f Dockerfile-static -t gocv-static .

Once it is built:

$ docker run gocv-static
gocv version: 0.38.0
opencv lib version: 4.10.0
$ docker run --rm -it --entrypoint bash gocv-static
root@5b28670af0d5:/# ls -l /run/gocv_version 
-rwxr-xr-x 1 root root 69112352 Sep 18 08:02 /run/gocv_version

@deadprogram deadprogram changed the title Static build tags all: correctly working static builds Sep 18, 2024
…f your own GoCV project. Note that HighGUI is not currently supported by static builds

Signed-off-by: deadprogram <[email protected]>
@deadprogram
Copy link
Member Author

deadprogram commented Sep 18, 2024

I have added another container called gocv-static-builder intended to help build user projects.

Build it like this:

docker build -f Dockerfile-static-builder -t gocv-static-builder .

Use it like this:

$ docker run --rm -e "BINARYNAME=mjpeg-streamer" -e "SRCPATH=./cmd/mjpeg-streamer" -v $(pwd):/src -v $(pwd)/build:/build -a stdout -a stderr gocv-static-builder
$ ls -l ./build/mjpeg-streamer
-rwxr-xr-x 1 root root 74471944 sep 18 12:06 ./build/mjpeg-streamer

Now you can run the static binary like this:

$ ./build/mjpeg-streamer 0 localhost:8080

@deadprogram
Copy link
Member Author

Did some further work and now the docker image is multiarch for both arm64 and amd64.

$ docker run --platform=linux/arm64 gocv-static
gocv version: 0.38.0
opencv lib version: 4.10.0

$ docker run --platform=linux/amd64 gocv-static
gocv version: 0.38.0
opencv lib version: 4.10.0

@deadprogram deadprogram merged commit 5e89541 into dev Sep 19, 2024
12 checks passed
@deadprogram deadprogram deleted the static-build-tags branch September 19, 2024 04:46
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

Successfully merging this pull request may close these issues.

1 participant