Skip to content
New issue

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

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

Already on GitHub? # to your account

Cross compilation fails #21

Closed
rolandjitsu opened this issue Jan 8, 2020 · 5 comments
Closed

Cross compilation fails #21

rolandjitsu opened this issue Jan 8, 2020 · 5 comments
Labels
question Further information is requested

Comments

@rolandjitsu
Copy link
Contributor

As reported in vmihailenco/taskq#55, if I try to cross compile a project that has a indirect dependency on this package I get:

❯ env GOOS=linux GOARCH=arm CGO_ENABLED=0 go build ./cmd/api/main.go                   
# github.com/valyala/gozstd
../../go/pkg/mod/github.com/valyala/gozstd@v1.6.2/stream.go:31:59: undefined: CDict
../../go/pkg/mod/github.com/valyala/gozstd@v1.6.2/stream.go:35:64: undefined: CDict
../../go/pkg/mod/github.com/valyala/gozstd@v1.6.2/stream.go:47:20: undefined: Writer
@valyala
Copy link
Owner

valyala commented Jan 8, 2020

Try running the following command before building the app:

cd ../../go/pkg/mod/github.com/valyala/gozstd && make clean libzstd.a

This command should re-build libzstd.a file for the host GOOS and GOARCH as mentioned in the FAQ.

@rolandjitsu
Copy link
Contributor Author

I managed to build it with a C cross compiler:

env CC=arm-linux-gnueabi-gcc GOOS=linux GOARCH=arm CGO_ENABLED=1 go build ./cmd/api/main.go 

But I could only do this on Linux. So I use docker to cross compile on a Mac.

I'm not sure if your suggestion would work if I do it on macOS and use the resulted binary on an ARM architecture.

@valyala valyala added the question Further information is requested label Jan 9, 2020
@valyala
Copy link
Owner

valyala commented Jan 9, 2020

I'm not sure if your suggestion would work if I do it on macOS and use the resulted binary on an ARM architecture.

My suggestion will work only when building binaries for host system. It doesn't work for cross-compilation :(

@rolandjitsu
Copy link
Contributor Author

I'm not sure if your suggestion would work if I do it on macOS and use the resulted binary on an ARM architecture.

My suggestion will work only when building binaries for host system. It doesn't work for cross-compilation :(

That's ok, it can be done using docker, so that's good enough I'd say. I will close this issue, but maybe it's worth mentioning in the docs that one must use a C cross compiler and the appropriate flags when cross compiling.

@valyala
Copy link
Owner

valyala commented Jan 11, 2020

maybe it's worth mentioning in the docs that one must use a C cross compiler and the appropriate flags when cross compiling.

Agreed. Could you prepare the corresponding pull request?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants