I have gone through all the solutions on stackoverflow as well as ask ubuntu.
I have a go program
package main
import "C"
//export Getint
func Getint() int {
return 2
}
func main() {}
and i have generated .so file for the same with name t.so and header file t.h
Now I would like to use this function in my C program. I have written the code but I don't know 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 with
gcc c.c t.so
it generates a.out file
but at the time of running a.out with ./a.out it gives error
./a.out
Error while loading shared libraries: t.so: can not open shared object file: no such file or directory exists.
then I tried with
gcc -c c.c -l t.so
so it generates c.o file and it is not executable.