1 /* There are two options: 2 3 =====1===== 4 5 Link this program with _embedding_test.so. 6 E.g. with gcc: 7 8 gcc -o embedding_test embedding_test.c _embedding_cffi*.so 9 10 You must then run the executable with the right command 11 (LD_LIBRARY_PATH on Linux), otherwise it won't find the 12 _embedding_cffi*.so: 13 14 LD_LIBRARY_PATH=. ./embedding_test 15 16 There are platform-specific options to gcc to avoid needing 17 that, too. Linux: 18 19 gcc -o embedding_test embedding_test.c _embedding_cffi*.so \ 20 -Wl,-rpath=\$ORIGIN/ 21 22 =====2===== 23 24 Compile and link the _embedding_test.c source code together with 25 this example (e.g. with PyPy): 26 27 gcc -o embedding_test embedding_test.c _embedding_cffi.c \ 28 -I/opt/pypy/include -pthread -lpypy-c 29 */ 30 31 #include <stdio.h> 32 33 extern int add(int x, int y); 34 35 main(void)36int main(void) 37 { 38 int res = add(40, 2); 39 printf("result: %d\n", res); 40 res = add(100, -5); 41 printf("result: %d\n", res); 42 return 0; 43 } 44