This is tricky (at least to me :-) , maybe unfeasible. But I try to ask to you.
I have this c shared library:
#include <stdio.h>
#include <stdlib.h>
static int variable = -666;
int get_value() {
return variable;
}
void print_pointer_to_get_value() {
printf("pointer_to_get_value: %p\n", &get_value);
}
Compiled this way (on Linux):
gcc -fPIC -c -O2 shared.c && gcc -shared -o shared.so shared.o
Now I load the library and call print_pointer_to_get_value():
>>> import ctypes
>>> so = ctypes.cdll.LoadLibrary('./shared.so')
>>> so.print_pointer_to_get_value()
pointer_to_get_value: 0x7f46e178f700
I'd like to get from ctypes the actual address, as integer, of the get_value function as printed by print_pointer_to_get_value(). My final target is to move that address to a Cython module and call that function inside a "nogil" Cython function. I need to load the .so library at runtime, therefore I cannot compile my Cython module linking it to the library.
Thanks 1000.