How can load dll in C?

L

Link

Dear,

How is the wonderful PYTHON for me.
It attracts me with its additional variety.

I am developing in C program as well as first to use C++ with extending &
embedding PYTHON.
It seems not to easy. What do I mean?

See that following steps what I am doing.

step 1. Success to make a example.dll with SWIG from MSVC6.0.
After, copy this DLL to C:\Python23\Lib.

step 2. Getting into Pythinwin to run the following commands.

step 3. Making a C file with MSVC6.0 and running.

void main()
{
//initialized the interpreter.
Py_Initialize();

//
int r0 = PyRun_SimpleString("import example\n");
int r1 = PyRun_SimpleString("c = example.new_Circle()\n");
int r2 = PyRun_SimpleString("print c\n");

//destory the interpreter
Py_Finalize();
}


The results:
1. See the step2,
To make a example.dll from MSV6.0 to be called by PYTHON.
Of course, it's OK.

2. See the step3,
while running the statement - 'PyRun_SimpleString("import example\n")'
missing to load the DLL and always return the value r0 = -1,


My quesions are:
1. example.dll can be called on Pythonwin but fail to load by C program.
2. Shall I set the PYTHONPATH while loading the DLL in C program?
If YES, How can I do?
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top