git2go与libssl和libssh2在单个二进制文件中的集成

huangapple go评论108阅读模式
英文:

git2go with libssl and libssh2 in single binary

问题

有人能提供一些建议(或资源),告诉我如何打包一个使用git2go、libssl和libssh2的GO程序,以便不需要最终用户单独安装这些库吗?

我只针对Linux发行版进行目标设置(如果有关系的话)。

英文:

Could anyone offer some suggestions (or resources) on how I could package a GO program that uses git2go, libssl and libssh2 such that it doesn't require the end user to install these libraries separately?

I am only targeting Linux distros (if it matters)

答案1

得分: 2

一种方法是将这些依赖项也静态构建,并使用PKG_CONFIG_PATH指向自己的副本,以便所有内容都被静态链接。这样,CMake就会选择静态版本。

但是,如果目标是避免依赖于用户安装的库,而不是将所有内容打包成一个可执行文件,我建议将库一起打包,并使用加载路径确保它们被加载。对于gcc,您可以通过在二进制文件本身中传递-Wl,-R来设置搜索路径,以便设置要搜索的共享库的位置。对于go,看起来可以通过链接器传递-r(通过-ldflags或手动方式)来实现相同的效果。

libgit2相当可扩展,因此还有第三种选择,即在Go中实现TLS流和SSH传输,并将其插入不支持这些功能的libgit2版本中。不过,这需要相当大量的工作量。

英文:

One way would be to build those dependencies statically as well and use PKG_CONFIG_PATH point to your own copies so everything gets linked statically. That should make CMake choose the static versions.

But if the goal is to avoid depending on the user-installed libraries rather than making everything a single executable, I would recommend shipping the libraries and working with the load path to make sure they get loaded. With gcc you'd pass -Wl,-R to set the search path in the binary itself, so you can set where to search for the shared libraries you're shipping with your app. With go it looks like you can pass -r to the linker (via -ldflags or manually) to do the same thing.

libgit2 is rather extensible, so there is a third option which is to implement the TLS stream and SSH transport in Go and plug those into a version of libgit2 without support for these. This is however a significant amount of work.

huangapple
  • 本文由 发表于 2015年12月18日 18:16:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/34353216.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定