-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[go] Support Linux and macOS via CGO #93
Comments
Hi qmuntal, this is a fantastic implementation, thank you so much. Do you think we should keep a seperate syscall implementation for windows or would that be a wrong move? Thank you! Alex |
Requiring gcc on windows for compiling C/C++ is the It can be done, but the benefits are minimal taking into account that installing |
Hi @qmuntal, thank you so much for your contribution! I have tried to go another round and use the cdynamic headers instead of the c headers. You can find my branch and commit here: A first prototype seems to work well for me, and avoids all linking issues you would have with the old version. Thank you, Alex |
@alexanderoster I'm not that familiarized with the c dynamic bindings generated by Despite I don't yet understand how it works, the name |
@qmuntal: Well, with external libraries, you usually have 3 options.
In our opinion, dynamic linking is the worst of the 3 options, since there is little control over where the library is loaded from (DLL Path security flaws are famous on Windows), and there is no control over error handling - immediately leading to DLL hells all over the place. I personally do not know any way of using a DLL with static linking. So ACT is usually as standard used with dynamic loading from absolute pathes. We usually always use use ACT heavily for plugin frameworks, and there the choosing a file location to load from is very essential. Do you think the current cgo headers allow GO to statically link .so files under Linux? Of so, we definitely should have a GoStatic option for the headers, but I still think that dynamic loading should be the default. For example then you can compile the Go executable with source code only and without having the final library in the same directory. Thank you, Alex |
Dynamic loading is not supported by |
The current auto-generated Go code is using
syscall.LoadLibrary
andsyscall.(*Proc).Call
to interop with C libraries. This methods are not implemented forlinux
normacOS
, and Go team has stated that they are not planning to do so, as the official FFI interface iscgo
, notsyscall
. More info in go#38825.cgo
is a full-featured Go/C interop framework which can be used in any OS and can be used to link go to link go to shared and static libraries. It has some inherent drawbacks, such as requiring a classic gcc/g++ tool-chain and complicating cross-compilation builds, yet it is the way to go in this situations. More info about cgo: link.Related: #91
The text was updated successfully, but these errors were encountered: