You can't call it from ctypes, you need at least to warp the function inside C so you could call it from Python.
I don't know the details of your function but for example if you have such this C++ code:
#include <iostream>
class Foo {
int bar;
public:
Foo(int bar) : bar(bar) {}
int getBar() const {
return bar;
}
void setBar(int bar) {
this->bar = bar;
}
void doSomething() const {
std::cout << bar << std::endl;
}
};
you can warp int this way:
// previous code here +
#define CAST_FOO(x) (static_cast<Foo *>(x))
#ifndef FOO_DEBUG
extern "C" {
#endif
void* foo_new(int bar) {
return static_cast<void*>(new Foo(bar));
}
int foo_get_bar(void *foo) {
return CAST_FOO(foo)->getBar();
}
void foo_set_bar(void *foo, int bar) {
CAST_FOO(foo)->setBar(bar);
}
void foo_do_something(void* foo) {
CAST_FOO(foo)->doSomething();
}
void foo_destroy(void* foo) {
delete CAST_FOO(foo);
}
#ifndef FOO_DEBUG
};
#endif
#ifdef FOO_DEBUG
int main(int argc, char **argv) {
void* foo = foo_new(10);
foo_do_something(foo);
foo_set_bar(foo, 20);
foo_do_something(foo);
foo_destroy(foo);
return 0;
}
#endif
now it should be callable from ctypes, and from C also.
$ g++ -Wall foo.cpp -DFOO_DEBUG
$ ./a.out
10
20
$ g++ -Wall foo.cpp -shared -o foo.so
$ python
>>> from ctypes import *
>>>
>>> so = cdll.LoadLibrary('foo.so')
>>> foo = so.foo_new(10)
>>>
>>> so.foo_do_something(foo)
10
>>> so.foo_set_bar(foo, 20)
>>> so.foo_do_something(foo)
20
>>> so.foo_destroy(foo)
>>>