Embedding Python in C DLL

T

terti

Hi,
// I need some help to embed the equivalent of the following Python code
in a C DLL.

from NLRclient import NLRclient
i = NLRclient("server")
s = i.getStrSort("qwerty")


// This what I have so far:

PyObject *module, *i;
PyObject *arg , *kw;

// The following I will put in the DllMain entrypoint
Py_Initialize();

// from NLRclient import NLRclient
module = PyImport_ImportModuleEx( "NLRclient", Py_BuildValue(""),
Py_BuildValue("") , Py_BuildValue( "", "NLRclient" ));

// i = NLRclient("server")
i = PyInstance_New( module, Py_BuildValue("s","server"),
Py_BuildValue(""));


Up to here the program compiles but when I run the application, I get a
runtime error dialog.





//This will be placed in one of the Dll functions
// s = i.getStrSort("qwerty")

How to I invoke a method from the created "i" instance ?



Py_Finalize();
return 0;


Many thanks,
Tertius
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top