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
golang - unable to use go library #41516
Comments
|
Hi @AlexRouSg , |
You should be able to use a C structure instead of a Go structure. |
does that mean If I have a go package which contains a go structure then convert this to C structure & create the lib using c-shared? |
Yes. As this is not a bug and the issue tracker is only for bugs, please see https://github.com/golang/go/wiki/Questions if you need further/more detailed help. |
Thanks. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?4.15.0-117-generic #118~16.04.1-Ubuntu SMP Sat Sep 5 23:35:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
What did you do?
Created a golang package 'test' using following commands
go install -buildmode=shared std
go install -buildmode=shared -linkshared test
above commands will create libstd.so and libtest.so under
go/pkg/linux_amd64_dynlink folder
Created a C program to use libtest.so
int main(int argc, char **argv) {
void *handle= dlopen ("libtest.so", RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
...
}
dlopen is failed with following error
libstd.so: undefined symbol: main.main
What did you expect to see?
dlopen should succeed
What did you see instead?
libstd.so: undefined symbol: main.main
This error is coming for any package. GOROOT and GOPATH are set correctly.
The text was updated successfully, but these errors were encountered: