I have the Go program:
package main
import "C"
//export Getint
func Getint() int {
return 2
}
func main() {}
and I have generated the .so file with the name t.so and header filet.h`
Now I would like to use the above function in my C program.
So had code but I am not knowing how to execute it.
#include <stdio.h>
#include <t.h>
int main()
{
int a;
a=Getint();
printf("number : %d",a);
return 0;
}
When I execute it using the below command:
gcc c.c t.so
It generates the a.out file
At the time of running the a.out with the command ./a.out it gives an error:
./a.out
Error while loading shared libraries:
t.so: can not open shared object file: no such file or directory exists.
So I tried with the command:
gcc -c c.c -l t.so
It generates a c.o file and it is not executable.