How can load dll in C?

Discussion in 'Python' started by Link, Sep 23, 2003.

  1. Link

    Link Guest

    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.

    >>> import example
    >>> c = example.new_Circle()
    >>> print c

    _a03f6e01_p_Circle
    >>>


    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?
     
    Link, Sep 23, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anushi
    Replies:
    5
    Views:
    8,845
  2. NGM
    Replies:
    0
    Views:
    2,332
  3. MN
    Replies:
    1
    Views:
    5,981
    =?Utf-8?B?TGVvbiBXZWxpY2tp?=
    Oct 9, 2004
  4. =?Utf-8?B?WW9nZXNoIEtldGthcg==?=

    System.DllNotFoundException: Unable to load DLL (ws2_32.dll).

    =?Utf-8?B?WW9nZXNoIEtldGthcg==?=, Mar 29, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,218
    =?Utf-8?B?WW9nZXNoIEtldGthcg==?=
    Mar 29, 2006
  5. H. Simpson
    Replies:
    4
    Views:
    308
    H. Simpson
    Aug 3, 2004
Loading...

Share This Page