Is there a Go equivalent to Python's ctypes library?

182 views
Skip to first unread message

Mark

unread,
Nov 21, 2023, 5:21:14 AM11/21/23
to golang-nuts
I would like to be able to access a dynamic C library (and ideally C++), i.e., `.so` or `.dll` _without_ using cgo, i.e., without needing a compiler on the target platform.
Python provides a `ctypes` module with this facility. Is there an equivalent for Go?

Mark

unread,
Nov 21, 2023, 5:54:11 AM11/21/23
to golang-nuts
Thank you, that looks just like what I want.

Tamás Gulácsi

unread,
Nov 21, 2023, 7:58:20 AM11/21/23
to golang-nuts
Which is what?
Please share with the golang-nuts list if you've found a solution!

Salih Muhammed

unread,
Nov 21, 2023, 8:51:48 AM11/21/23
to Mark, golan...@googlegroups.com


I know that there's purego https://github.com/ebitengine/purego but not
totally sure about it can preform without a compiler.

--
Regards,
Salih

Mark

unread,
Nov 21, 2023, 10:29:58 AM11/21/23
to golang-nuts
My reply was to Salih but somehow my reply ended up appearing first.

According to the purego docs you don't need a compiler, essentially it provides a means of opening a dll/so and registering and calling functions within the dll/so.
Reply all
Reply to author
Forward
0 new messages