1月 082019
 

go的非常大的优势在于编译后是无依赖的,然而,如果go里面掺杂了c的代码(多半是要借助现有的c的类库),编译后的程序就有依赖了,就不能随便拿走运行了,还要安装依赖才能运行。

其实,c的程序也可以运行时无依赖的,就是所谓的静态编译,这个需要依赖库提供静态库文件;于是,cgo也能静态编译,使得编译后的程序无依赖。

尽管如此,静态编译是稍微麻烦一些的,所有的依赖库都需要有静态库文件,最终可能还是编译失败。

尝试一下mylg的静态编译:

该工具依赖了libpcap

 Posted by at 下午 2:55

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据