bimg: Unable to build for linux on mac
When trying to build for linux on Mac Big Sur (11.0.1) I get an error. I have seen previous issue (https://github.com/h2non/bimg/issues/151) however it remains unsolved. I can build for Mac perfectly fine.
Code
package main
import "github.com/h2non/bimg"
func main() {
bimg.Read("jamaica.png")
}
Build attempt
GOOS=linux go build
Resulting error
# github.com/h2non/bimg
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:93:49: undefined: Gravity
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:133:29: undefined: Watermark
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:139:34: undefined: WatermarkImage
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:152:26: undefined: Angle
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:181:31: undefined: Interpretation
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:202:27: undefined: Options
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:212:29: undefined: ImageMetadata
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:218:35: undefined: Interpretation
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/image.go:234:25: undefined: ImageSize
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/resize.go:11:27: undefined: Options
../../../go/pkg/mod/github.com/h2non/bimg@v1.1.5/resize.go:11:27: too many errors
Vips version: vips-8.10.2-Mon Oct 12 16:43:59 UTC 2020
Go version: go version go1.15.3 darwin/amd64
Go env:
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/wpc/Library/Caches/go-build"
GOENV="/Users/wpc/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/wpc/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/wpc/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/wpc/Projects/go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/19/t_ym7y7974bcn4s78jn5kvr40000gn/T/go-build192137903=/tmp/go-build -gno-record-gcc-switches -fno-common"
If I build using
CGO_ENABLED=1 GOOS=linux go build
I get different error saying
# enumertest/debugbimg
/usr/local/go/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: ignoring file /var/folders/19/t_ym7y7974bcn4s78jn5kvr40000gn/T/go-link-246081632/go.o, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 )
Undefined symbols for architecture x86_64:
"__cgo_topofstack", referenced from:
__cgo_68a45036e746_Cfunc_has_alpha_channel in 000004.o
__cgo_68a45036e746_Cfunc_has_profile_embed in 000004.o
__cgo_68a45036e746_Cfunc_interpolator_window_size in 000004.o
__cgo_68a45036e746_Cfunc_vips_affine_interpolator in 000004.o
__cgo_68a45036e746_Cfunc_vips_autorot_bridge in 000004.o
__cgo_68a45036e746_Cfunc_vips_avifsave_bridge in 000004.o
__cgo_68a45036e746_Cfunc_vips_colourspace_bridge in 000004.o
...
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestions?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 18 (3 by maintainers)
Hum I need use this lib on docker image alpine:3.15.6
The problem is the CGO part - you need the libvips headers for the system you want to compile for. Cross-compiling with CGO can be tricky.