git2go在单个二进制文件中使用libssl和libssh2 [英] git2go with libssl and libssh2 in single binary

查看:262
本文介绍了git2go在单个二进制文件中使用libssl和libssh2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以提供一些关于如何打包使用git2go,libssl和libssh2的GO程序的建议(或资源),以便它不要求最终用户单独安装这些库?



我只针对Linux发行版(如果有要求的话)

解决方案

一种方法是构建这些依赖关系也是静态的,并使用 PKG_CONFIG_PATH 指向您自己的副本,以便静态地链接所有内容。这应该让CMake选择静态版本。



但是,如果目标是避免依赖用户安装的库而不是将所有内容都制作为单个可执行文件,那么我会推荐发货库和加载路径,以确保它们被加载。使用 gcc ,您可以传递 -Wl,-R 来设置二进制本身的搜索路径,这样您就可以设置在哪里搜索您的应用随附的共享库。使用 go ,看起来您可以将 -r 传递给链接器(通过 -ldflags 或手动)执行相同的操作。

libgit2具有相当的可扩展性,因此还有第三种选择是实现TLS流和SSH使用Go进行传输并将其插入到libgit2的版本中,但不支持这些版本。然而,这是一项重要的工作。

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)

解决方案

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.

这篇关于git2go在单个二进制文件中使用libssl和libssh2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆