Calling C/C++ functions in a python script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chaosquant@tele2.fr

    #1

    Calling C/C++ functions in a python script

    I'm kind of beginner in Python, so I must ask what are probably silly
    questions.

    Here is my problem:

    I have a static library say, a file library.lib, which can be linked to
    C or C++ programs.

    Now I would like to use the functions of the library in Python script,
    under Win XP.

    Can someone give me a simple example of how to do so?

    Thanks a lot,

    Jean-Claude

    Please reply also to chaosquant@tele 2.fr

  • Ravi Teja

    #2
    Re: Calling C/C++ functions in a python script

    If all you have are functions, the easiest is to create a simple dll/so
    and load it into Python with ctypes.


    For more advanced needs, take a look at some of the extending options
    available.


    Comment

    • chaosquant@tele2.fr

      #3
      Re: Calling C/C++ functions in a python script


      Ravi Teja a écrit :
      [color=blue]
      >
      > For more advanced needs, take a look at some of the extending options
      > available.
      > http://www.suttoncourtenay.org.uk/du...ingpython.html[/color]

      Thanks for your answer. It is just what I'm trying to do.
      Unfortunately, apparently I need a
      "pyhton24_d.lib " to link to that does not seem to exists. Do you know a
      solution for this?

      Thanks a lot,

      Jean-Claude

      Comment

      • Carl

        #4
        Re: Calling C/C++ functions in a python script

        chaosquant@tele 2.fr wrote:
        [color=blue]
        >
        > Ravi Teja a écrit :
        >[color=green]
        >>
        >> For more advanced needs, take a look at some of the extending options
        >> available.
        >> http://www.suttoncourtenay.org.uk/du...ingpython.html[/color]
        >
        > Thanks for your answer. It is just what I'm trying to do.
        > Unfortunately, apparently I need a
        > "pyhton24_d.lib " to link to that does not seem to exists. Do you know a
        > solution for this?
        >
        > Thanks a lot,
        >
        > Jean-Claude[/color]

        You can be build it from source! /Carl

        Comment

        • Ravi Teja

          #5
          Re: Calling C/C++ functions in a python script

          You are working with the debug configuration, use release instead and
          python24.lib will suffice.



          Comment

          Working...