Created
August 28, 2013 08:56
-
-
Save lbolla/6363780 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void foo() { | |
printf("Hello world\n"); | |
} | |
int bar() { | |
return 1; | |
} | |
int baz(int n) { | |
int sum = 0; | |
for (int i = 0; i < n; i++) { | |
sum += i; | |
} | |
return sum; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
libgo = ctypes.cdll.LoadLibrary('./libgo.so') | |
libgo.foo() | |
print(libgo.bar()) | |
print(libgo.baz(100)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: go.so | |
go.o: go.c | |
gcc -std=c99 -c -fPIC go.c -o go.o | |
go.so: go.o | |
gcc -shared -Wl,-soname,libgo.so -o libgo.so go.o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment