英文:
Golang compile with main package code and .a files?
问题
在我的情况下,我需要发布我的库项目,但不包含源代码,只有编译后的形式。
给定以下条件:
- 一些以编译后的 .a 文件形式存在的库包
- 一个以源代码形式存在的主包
- 所有它们构建的平台类型匹配
是否可能将主包编译并将其与 .a 文件链接成一个可执行文件?如果可行,应该如何操作?
英文:
In my scenario I'll need to release my lib project without source code but a compiled form.
Given,
- Some library package in the form of compiled .a files,
- a main package in form of source code,
- all their platform types where they're built on match,
is it possible to compile the main and link it with .a files up into an executable? How to do it if doable?
答案1
得分: 1
除非“.a”文件是通过“安装”(go get或go install)一个包生成的,否则不行。一个“.a”库文件是根据将要使用它的环境的操作系统、机器架构、go版本等进行“定制”的。你的库的用户可能不满足所有的要求。因此,没有源代码的“.a”文件是没有用的,可能还有其他原因。
英文:
Not unless the .a files were generated as a result of "installing" (go get or go install) a package. A ".a" library file is "customized" for the OS, machine architecture, go version etc. of the environment in which it will be used. Users of your library are not likely to meet all of the requirements. For that reason, and perhaps others, ".a" files without source code are not useful.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论