JohnGalt
JohnGalt

Reputation: 429

Cross compiled pkg import in Go

I would like to use a go module named "go-yara" on Windows, which I cross-compiled on a Debian based Linux system. Everything works as expected. The build creates a go-yara.a file in the $GOPATH/pkg/windows_386/github.com/hillu/ folder.

enter image description here

However when I try to use the module in a go program it seem that it tries to recompile the module from the src stating that a yara.h file is missing. Yes, that's correct. There is no yara.h on Windows. It's much easier for me to compile yara and its headers on Linux.

enter image description here

This file is indeed needed during during cross-compilation on Linux. Why do I need it on Windows too? Isn't the go-yara.a in the pkg folder enough? Why does it ignore the .a file and tries to compile the module from its source? Can I force it to use the precompiled module in the pkg folder?

I am new to Golang so please excuse my ignorance.

Upvotes: 0

Views: 139

Answers (1)

Sean
Sean

Reputation: 1088

According to the go-yara instructions you need to compile both on the Debian machine. The Go compilation instructions on go-yara shows it is cross compiling on the debian machine for windows 386. So you would run both on your Debian build machine and then copy over the windows binary to run the application.

Upvotes: 3

Related Questions