lestrrat-go / libxml2

Interface to libxml2, with DOM interface
MIT License
230 stars 55 forks source link

Cross compile from macos #57

Closed FrankIT60 closed 5 years ago

FrankIT60 commented 5 years ago

Ciao,

when I try to cross-compile with this env from macos,

GOARCH=amd64
GOOS=freebsd
CGO_ENABLED=0

PATH=$GOROOT/bin:$PATH:/usr/local/bin

get this errors:

# github.com/lestrrat-go/libxml2/xsd
../../../github.com/lestrrat-go/libxml2/xsd/xsd.go:29:15: undefined: clib.XMLSchemaParse
../../../github.com/lestrrat-go/libxml2/xsd/xsd.go:40:15: undefined: clib.XMLSchemaParseFromFile
../../../github.com/lestrrat-go/libxml2/xsd/xsd.go:55:12: undefined: clib.XMLSchemaFree
../../../github.com/lestrrat-go/libxml2/xsd/xsd.go:65:10: undefined: clib.XMLSchemaValidateDocument
# github.com/lestrrat-go/libxml2/xpath
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:40:30: undefined: clib.XMLXPathObjectType
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:45:9: undefined: clib.XMLXPathObjectFloat64
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:50:9: undefined: clib.XMLXPathObjectBool
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:74:13: undefined: clib.XMLXPathObjectNodeList
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:91:13: undefined: clib.XMLXPathObjectNodeList
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:124:2: undefined: clib.XMLXPathFreeObject
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:129:14: undefined: clib.XMLXPathCompile
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:149:2: undefined: clib.XMLXPathFreeCompExpr
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:163:17: undefined: clib.XMLXPathNewContext
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:179:9: undefined: clib.XMLXPathContextSetContextNode
../../../github.com/lestrrat-go/libxml2/xpath/xpath.go:179:9: too many errors

with this env:

GOARCH=amd64
GOOS=freebsd
CGO_ENABLED=1

PATH=$GOROOT/bin:$PATH:/usr/local/bin

get this errors:

# runtime/cgo
gcc_freebsd_amd64.c:46:2: error: implicit declaration of function 'SIGFILLSET' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gcc_freebsd_amd64.c:46:13: error: variable 'ign' is uninitialized when used here [-Werror,-Wuninitialized]
gcc_freebsd_amd64.c:41:14: note: initialize the variable 'ign' to silence this warning

Any idea?

T.I.A. Franco

lestrrat commented 5 years ago

CGO_ENABLED=0 means it doesn't compile the C/Go bridge. So the first example can't work. And remember: (pure) Go supports cross platform compilation, but C does not. Therefore you can't cross compile on a mac for freebsd when cgo is in action. Run it on a freebsd machine.

Rockyzsu commented 1 year ago

@lestrrat Hi, is that mean it can't work on windows if i dont build it with visual studio or cgywin like?

lestrrat commented 1 year ago

It's the same as when you are building a C program. You build in the same arch/os as the where you intend to run the program.

Rockyzsu commented 1 year ago

It's the same as when you are building a C program. You build in the same arch/os as the where you intend to run the program.

Thanks a lot. Instsall vs environment taks lots of time, so i switch to the ubuntu to "quick fix this issue" :(

lestrrat commented 1 year ago

That works too!