英文:
Cross compiled pkg import in Go
问题
我想在Windows上使用一个名为"go-yara"的Go模块,我在基于Debian的Linux系统上进行了交叉编译。一切都按预期工作。构建过程在"$GOPATH/pkg/windows_386/github.com/hillu/"文件夹中创建了一个"go-yara.a"文件。
然而,当我尝试在Go程序中使用该模块时,似乎它试图从源代码重新编译该模块,并指出缺少一个"yara.h"文件。是的,这是正确的。在Windows上没有"yara.h"文件。对我来说,在Linux上编译yara及其头文件要容易得多。
在Linux上进行交叉编译时确实需要这个文件。为什么在Windows上也需要它呢?难道"pkg"文件夹中的".a"文件不足够吗?为什么它忽略了".a"文件并尝试从源代码编译该模块?我能强制它使用"pkg"文件夹中的预编译模块吗?
我对Golang还不熟悉,请原谅我的无知。
英文:
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.
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.
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.
答案1
得分: 3
根据go-yara的说明,你需要在Debian机器上进行编译。go-yara的Go编译说明显示它在Debian机器上进行交叉编译,用于Windows 386。因此,你需要在Debian构建机器上同时运行两者,然后将Windows二进制文件复制过去以运行应用程序。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论