Build a Windows DLL #5821
Unanswered
PhineasCampbell
asked this question in
Q&A
Replies: 1 comment
-
For clarity this is the function signature PYBIND11_MODULE(bind, m, py::mod_gil_not_used()) To show I have called the module bind, rather than example as in the example |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi I am trying to build a Windows DLL using the example on the getting started page. I can build using Visual Studio and load the dll, however, in a Python instance I get:
import bind as b
b.add(4,5)
Which gives the error
AttributeError: module 'bind' has no attribute 'add'
Now a Windows dll must have a set of exports which I define in the file bind.h which I post here
#pragma once
#ifdef BIND_EXPORTS
#define BIND_API __declspec(dllexport)
#else
#define BIND_API __declspec(dllimport)
#endif
extern "C" BIND_API PyObject* PyInit_bind();
extern "C" BIND_API int add(int i, int j);
Note I have exported the add directly, which I am able to call using the ctypes library. Is it possible to make the add visible in a Windows dll? I have tried PyInit_bind(); function signature with and without void, as expected it makes no difference. As it stands the dll exports 2 functions the direct add and PyInit_bind
Phineas
Beta Was this translation helpful? Give feedback.
All reactions