473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Extending Python with C++

I am learning how to extend Pythong with C++. I have will be writing
some code in C++ and want/need Python to interact with it. I am not
having success following the online documentation from
http://docs.python.org/ext/ext.html. I have also looked briefly at
some of the demos in the source code distribution. Can anyone help me?
I am using the MacPython (version 2.4) distribution.

I have one specific question. The documentation online states:

"If the main program (the Python interpreter) is compiled and linked by
the C compiler, global or static objects with constructors cannot be
used. This is not a problem if the main program is linked by the C++
compiler."

Thanks,
Jeremy

Dec 29 '05 #1
6 1666
"jeremito" <je******@gmail.com> wrote:
I have one specific question. The documentation online states:

"If the main program (the Python interpreter) is compiled and linked by
the C compiler, global or static objects with constructors cannot be
used. This is not a problem if the main program is linked by the C++
compiler."


what is the question ?

</F>

Dec 29 '05 #2
Oops, sorry. My question is, how can I know if my Python interpreter
was lined by C++? The non-specific questions are, of course, does
anyone have any hints or suggestions? Good websites to visit?
Thanks,
Jeremy

Dec 29 '05 #3
jeremito said unto the world upon 29/12/05 11:39 AM:
I am learning how to extend Pythong with C++. I have will be writing
some code in C++ and want/need Python to interact with it. I am not
having success following the online documentation from
http://docs.python.org/ext/ext.html. I have also looked briefly at
some of the demos in the source code distribution. Can anyone help me?
I am using the MacPython (version 2.4) distribution.

I have one specific question. The documentation online states:

"If the main program (the Python interpreter) is compiled and linked by
the C compiler, global or static objects with constructors cannot be
used. This is not a problem if the main program is linked by the C++
compiler."

Thanks,
Jeremy


I have a specific answer.

Best,

Brian vdB
Dec 29 '05 #4
jeremito wrote:
Oops, sorry. My question is, how can I know if my Python interpreter
was lined by C++?
Ah. This documentation fragment is somewhat wrong: it depends on the
target operating system and compiler whether you have to link main
with a C++ compiler. For many modern systems, this isn't necessary.

Anyway, finding out whether the executable was linked with a C++
compiler is only possible with platform-dependent tools. For example,
on Linux and many Unix systems, ldd(1) will tell you whether a C++
library was linked into the binary; do 'ldd python'.
The non-specific questions are, of course, does
anyone have any hints or suggestions?


You should really understand the concept of 'extern "C"' in C++.
That's all you need to know write Python extensions in C++.

Regards,
Martin
Dec 29 '05 #5
Brian van den Broek said unto the world upon 29/12/05 12:03 PM:
jeremito said unto the world upon 29/12/05 11:39 AM:
I am learning how to extend Pythong with C++. I have will be writing
some code in C++ and want/need Python to interact with it. I am not
having success following the online documentation from
http://docs.python.org/ext/ext.html. I have also looked briefly at
some of the demos in the source code distribution. Can anyone help me?
I am using the MacPython (version 2.4) distribution.

I have one specific question. The documentation online states:

"If the main program (the Python interpreter) is compiled and linked by
the C compiler, global or static objects with constructors cannot be
used. This is not a problem if the main program is linked by the C++
compiler."

Thanks,
Jeremy

I have a specific answer.

Best,

Brian vdB

Hello all,

while I think the point I was making was correct, I know I expressed
it in a snide and unkind way. Apologies to all, especially to the OP.

Sheepishly,

Brian vdB
Dec 29 '05 #6
Unfortunately, I need to know a bit more than just the concept 'extern
"C"'. I am really slow at this. Can anyone point me towards some
examples or a tutorial (other than the one from python.org, I didn't
understand that one)?
Thanks,
Jeremy

Dec 30 '05 #7

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

Similar topics

4
by: Alicia Haumann | last post by:
I accidentally sent this to webmaster@python.org, so this could be a duplicate if "webmaster" forwards it to this list. :{ Hi, there. Thanks for any help that can be offered. I've been...
3
by: stefan | last post by:
Hi Folks, I currenty extended some of my C++ functionality to python and also embedded python to use python functionality in my C++ system (and use as well these extended functions). While...
1
by: Richard Townsend | last post by:
In the "Extending and Embedding" part of the Python documentation: section 5.4 "Extending Embedded Python" - it describes how to use a Python extension module from Python that is embedded in a C...
3
by: Marco Meoni | last post by:
Hi all! I've a problem with a C++ class that has to be included in a python application. One way to do it is Extending and Embedding the Python Interpreter Now i have 2 questions 1) Is there a...
5
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where...
3
by: Redefined Horizons | last post by:
I'm trying to understand the argument flags that are used in the method table of an extension module written in C. First let me ask this question about the method table. Is it an C array named...
1
by: jeremito | last post by:
I am trying to learn how to extend and/or embed Python. I have looked at the document "Extending and Embedding the Python Interpreter" and also "Python/C API Reference Manual. In the examples...
6
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python...
7
by: Maximus Decimus | last post by:
HI all, I am using python v2.5 and I am an amateur working on python. I am extending python for my research work and would like some help and guidance w.r.t this matter from you experienced...
0
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.