openssl: Strange error with GOOS=windows _OR_ GOARCH=386
I can not find any explanation to the error as Ctx is clearly defined in ctx.go. This only happens when GOOS=windows and or GOARCH=386. Trying with latest 1.10.2 golang:
dmagyar@dmtest:~/go/ossl$ GOOS=windows GOARCH=amd64 go get github.com/spacemonkeygo/openssl
# github.com/spacemonkeygo/openssl
../src/github.com/spacemonkeygo/openssl/net.go:24:7: undefined: Ctx
dmagyar@dmtest:~/go/ossl$ GOOS=linux GOARCH=amd64 go get github.com/spacemonkeygo/openssl
dmagyar@dmtest:~/go/ossl$ GOOS=linux GOARCH=386 go get github.com/spacemonkeygo/openssl
# github.com/spacemonkeygo/openssl
../src/github.com/spacemonkeygo/openssl/net.go:24:7: undefined: Ctx
dmagyar@dmtest:~/go/ossl$
Any ideas what this could be?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (6 by maintainers)
The reason it is out of scope is because it really has nothing to do with Go, and much more to do with cross-compiling openssl. Once you have successfully cross-compiled openssl, configuring Go to use your cross compilation toolchain is pretty straightforward. There are a good number of resources out there that can help.
Cross-compilation using a macOS host can be a colossal pain. Getting a macOS toolchain targeting linux can be very easy or very hard depending on your requirements. If you are targeting linux/amd64 then you can probably download a prebuilt one (brew even has some available if you are ok using musl). If you have requirements around architecture (e.g. ARM) and C library (e.g. gcc, musl, uclibc) then things get a little trickier. You can use something like crosstool-ng to build a toolchain, but not without pain (mostly due to gnu tool behavior and file system case sensitivity).
Other platforms aren’t as difficult. I’ve successfully cross-compiled openssl (and this wrapper) for windows from linux, but that was considerably easier because mingw-w64 toolchains are readily available on linux.
@dmagyar , I think this code (
net.go:24) needscgo. So, we need to set atleast 2 environment variables:I had the same issue, and got this resolved by adding these 2 environment variables along with
GOOSandGOARCHHope it helps.