gokogiri icon indicating copy to clipboard operation
gokogiri copied to clipboard

compilation errors/warnings

Open mattetti opened this issue 11 years ago • 4 comments

When I cross compile my app using gokogiri, I get the following messages:

compiling for linux-386
# github.com/moovweb/gokogiri/xml
../../../github.com/moovweb/gokogiri/xml/attribute.go:4: undefined: XmlNode
../../../github.com/moovweb/gokogiri/xml/cdata.go:4: undefined: XmlNode
../../../github.com/moovweb/gokogiri/xml/element.go:4: undefined: XmlNode
../../../github.com/moovweb/gokogiri/xml/nodeset.go:6: undefined: Document
../../../github.com/moovweb/gokogiri/xml/nodeset.go:7: undefined: Node
../../../github.com/moovweb/gokogiri/xml/nodeset.go:11: undefined: Document
../../../github.com/moovweb/gokogiri/xml/nodeset.go:16: undefined: Node
../../../github.com/moovweb/gokogiri/xml/nodeset.go:20: undefined: Node
../../../github.com/moovweb/gokogiri/xml/nodeset.go:22: undefined: NewNode
../../../github.com/moovweb/gokogiri/xml/text.go:4: undefined: XmlNode
../../../github.com/moovweb/gokogiri/xml/nodeset.go:22: too many errors
compiling for linux-amd64
# github.com/moovweb/gokogiri/xml
../../../github.com/moovweb/gokogiri/xml/attribute.go:4: undefined: XmlNode
../../../github.com/moovweb/gokogiri/xml/cdata.go:4: undefined: XmlNode
../../../github.com/moovweb/gokogiri/xml/element.go:4: undefined: XmlNode
../../../github.com/moovweb/gokogiri/xml/nodeset.go:6: undefined: Document
../../../github.com/moovweb/gokogiri/xml/nodeset.go:7: undefined: Node
../../../github.com/moovweb/gokogiri/xml/nodeset.go:11: undefined: Document
../../../github.com/moovweb/gokogiri/xml/nodeset.go:16: undefined: Node
../../../github.com/moovweb/gokogiri/xml/nodeset.go:20: undefined: Node
../../../github.com/moovweb/gokogiri/xml/nodeset.go:22: undefined: NewNode
../../../github.com/moovweb/gokogiri/xml/text.go:4: undefined: XmlNode
../../../github.com/moovweb/gokogiri/xml/nodeset.go:22: too many errors

Everything works well for darwin tho.

mattetti avatar Jul 22 '13 05:07 mattetti

Are you cross compiling in a Darwin machine? The C bindings are dynamically linked libraries that need to exist in your system. Because the libraries are specific to each operating system (libxml in darwin is different than libxml in linux), you can't cross compile gokogiri for multiple platforms in the same machine.

What you'd have to do is get a machine that mimics the target machine you're trying to compile for and compile the code strictly for that there. So if you need linux_i386, linux_amd64, and darwin, then you need three machines, one of each, and you can compile your code on each one individually.

mdayaram avatar Jul 22 '13 07:07 mdayaram

That's what I was afraid of :( I guess I will need to setup vagrant. Isn't there a way around where the libraries compiled for each platform are available on my darwin machine and linked at compile time? Seems unlikely but just checking all my options.

mattetti avatar Jul 22 '13 07:07 mattetti

Hmmm, I haven't really tried it, but I guess it would be possible to point the go compiler to different locations for different libraries when compiling for different OSes, each location containing libraries that have been compiled for those systems.

mdayaram avatar Jul 24 '13 01:07 mdayaram

Actually, that would depend on whether the linkers used can link a library that was not compiled for this system, and I doubt the linker in a linux computer knows what the hell to do with a .dylb file from mac =/ I doubt it's possible.

mdayaram avatar Jul 24 '13 01:07 mdayaram