在其他操作系统上编译时,Go程序如何链接系统库?

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

How does go program link system libs, when compiled on other OS?

问题

我了解GO代码可以编译为不同的平台(操作系统)。

假设我在Windows上为Linux编译。
如果我需要依赖于Linux系统库,这个依赖关系是如何解决的?

英文:

I understand GO code can be compiled for different platforms (OS). <br>

Lets say I compile on Windows for Linux.
If I need a dependency to a Linux system lib - how is this dependency resolved?

答案1

得分: 0

似乎需要引用另一个操作系统的系统库,例如在从Windows编译时引用Linux系统库,那么这些Linux系统库必须存在于Windows系统中。

同样的情况也适用于使用特殊库,例如使用"cgo"调用C库时,可能会实现一些特定设备功能。例如,在咖啡机上,可以使用这些函数来开始制作咖啡或清洁机器。

英文:

It seems, like to reference system libs of another OS,
for example linux system libs when compiling from windows -
the linux system libs must be present on the windows system.

The same would be the case, when using special libs, for example when calling c-libs using "cgo", which maybe could implement some device specific functions.
For example on a coffee machine - the functions which starts making coffee or cleaning the machine.

huangapple
  • 本文由 发表于 2017年6月29日 19:14:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/44823580.html
匿名

发表评论

匿名网友

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

确定