473,573 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ch********@tele 2.fr

May 10 '06 #1
4 1416
If all you have are functions, the easiest is to create a simple dll/so
and load it into Python with ctypes.
http://starship.python.net/crew/thel.../tutorial.html

For more advanced needs, take a look at some of the extending options
available.
http://www.suttoncourtenay.org.uk/du...ingpython.html

May 10 '06 #2

Ravi Teja a écrit :

For more advanced needs, take a look at some of the extending options
available.
http://www.suttoncourtenay.org.uk/du...ingpython.html


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

May 11 '06 #3
ch********@tele 2.fr wrote:

Ravi Teja a Ă©crit :

For more advanced needs, take a look at some of the extending options
available.
http://www.suttoncourtenay.org.uk/du...ingpython.html


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


You can be build it from source! /Carl
May 11 '06 #4
You are working with the debug configuration, use release instead and
python24.lib will suffice.

http://news.hping.org/comp.lang.pyth...hive/6741.html

May 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
16018
by: Charles Larry | last post by:
Is there a way to define functions after the main part of a Python script? Example: #!/usr/local/bin/python # this code yields a NameError print_message("hello world")
18
5287
by: bart_nessux | last post by:
I need a script to call several functions at the same time. How does one call more than one function simultaneously?
22
6297
by: Brad Tilley | last post by:
Is it possible to write a file open, then read program in C and then call the C program from a Python script like this: for root, files, dirs in os.walk(path) for f in files: try: EXECUTE_C_PROGRAM If possible, how much faster would this be over a pure Python solution?
1
1733
by: delrocco | last post by:
Hello, I really appreciate anyone who has time to read this and help, Thanks up front. I'm very new to python, having picked it up for the first time a week ago, but I feel I'm very close to getting this working. Here's what I'm trying to do: - call python scripts from game code - have those called scripts call functions that are back...
6
1543
by: Yevgeniy (Eugene) Medynskiy | last post by:
Hi all, This is probably a very newbie question, but after searching google and docs @ python.org I can't find an answer, so maybe someone would be able to help? I'd like to call command-line functions from my python script (like you would in perl using backticks)... Is there a way of doing this? And if so, how does the environment get...
3
3995
by: Mohammed Smadi | last post by:
Hi; Does anyone know if we can call matlab for a python or bash script while feeding the matlab script some command line arguments? I have an interactive matlab script which i want to automate by feeding the args from a script. I know this is probably more suitable to a matlab group but any ideas will be appreciated.
3
5446
by: David Bear | last post by:
I have a hash function written by another organization that I need to use. It is implemented in perl. I've been attempting to decode what they are doing in their hash function and it is taking way too long. I've identified two functions in a perl module that I would like to 'call' from a python program. I found the following:...
2
2111
by: Graham Menhennitt | last post by:
I have a large Python 2.5 program that I want my users to be able to "extend" using a Python script. However, I want their script to run in a sandbox within the overall program so that they only have access to the rest of the program via a single simple interface. Note that this is not meant to be a real anti-hacker type security sandbox -...
1
2206
by: joeedh | last post by:
Hi I'm getting extremely odd behavior. First of all, why isn't PyEval_EvalCode documented anywhere? Anyway, I'm working on blender's python integration (it embeds python, as opposed to python embedding it). I have a function that executes a string buffer of python code, fetches a function from its global dictionary then calls it. When...
0
7710
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8039
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8222
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7800
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6437
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5296
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2230
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1049
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.