gpt4 book ai didi

shared-libraries - 我可以在 Go 中使用共享对象吗?

转载 作者:IT王子 更新时间:2023-10-29 01:34:19 24 4
gpt4 key购买 nike

我可以在 Go 中使用共享对象吗?

最佳答案

根据围棋FAQ ,您可以使用“外部函数接口(interface)”调用 C 库:

Do Go programs link with C/C++ programs?

There are two Go compiler implementations, 6g and friends, generically called gc, and gccgo. Gc uses a different calling convention and linker and can therefore only be linked with C programs using the same convention. There is such a C compiler but no C++ compiler. Gccgo is a GCC front-end that can, with care, be linked with GCC-compiled C or C++ programs. However, because Go is garbage-collected it will be unwise to do so, at least naively.

There is a “foreign function interface” to allow safe calling of C-written libraries from Go code. We expect to use SWIG to extend this capability to C++ libraries. There is no safe way to call Go code from C or C++ yet.

回答您之前关于 Windows DLL 的问题:不,因为目前没有 Go 的 Windows 实现。有关详细信息,请阅读 can-go-compiler-be-installed-on-windows

关于shared-libraries - 我可以在 Go 中使用共享对象吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2254777/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com