473,396 Members | 1,714 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,396 software developers and data experts.

embed python

Can somebody tell me how to handle
this #include issue when embedding python?
Why NOT (according to the python doc) ude
#include <python2.3/Python.h>
?

And which is the library to link if I want to
use pyhton from my application?

Is there a standard way to deal with that issue?

thanks,
marc

Jul 18 '05 #1
4 1442
In article <c2***********@news.riken.go.jp>, Marc Schellens wrote:
Can somebody tell me how to handle
this #include issue when embedding python?
Usually "#include "Python.h" is the right way. Then tell your compiler
to add "python2.3" to the include list. On gcc pass "-I/usr/include/python2.3"
or similar to the compilation step.
Why NOT (according to the python doc) ude
#include <python2.3/Python.h>
?
Well, you actually can do that, it will work just as above way. But when
you upgrade your Python to 2.4, you need to change your sourcecode. Otherwise
you only need to change your Makefile.

Maybe there is another, more important reason. I don't know. :)

And which is the library to link if I want to
use pyhton from my application?


-lpython2.3 (or -lpython23 on some systems) will find the right library,
which is libpython2.3.so in most cases (or libpython23.so or python23.dll
if you are on Win32).
Peter
Jul 18 '05 #2
Thanks Peter,
In article <c2***********@news.riken.go.jp>, Marc Schellens wrote:
Can somebody tell me how to handle
this #include issue when embedding python?

Usually "#include "Python.h" is the right way. Then tell your compiler
to add "python2.3" to the include list. On gcc pass "-I/usr/include/python2.3"
or similar to the compilation step.
Why NOT (according to the python doc) ude
#include <python2.3/Python.h>
?

Well, you actually can do that, it will work just as above way. But when
you upgrade your Python to 2.4, you need to change your sourcecode. Otherwise
you only need to change your Makefile.


ok, but why everybody writes #include "Python.h" instead of
#include <Python.h> ? The latter form is the corrcet one for
header files wich are not part of the actual project.

marc

Jul 18 '05 #3
In article <c3***********@news.riken.go.jp>, Marc Schellens wrote:
Usually "#include "Python.h" is the right way.
ok, but why everybody writes #include "Python.h" instead of
#include <Python.h> ? The latter form is the corrcet one for
header files wich are not part of the actual project.


Yes, you are right. Should be <Python.h>. I was sloppy in my post.
GCC should be generous and accept "Python.h", too, but it might not
work with all compilers.

I checked my current project code, it has <Python.h>. I don't know what
everyone else writes. :)

Not exactly related to your question, but if you are doing embedding,
have a look at Pyrex which can be misused for extremely simple embedding
as it saves you the need to write all the C boilerplate code. This isn't
exactly what Pyrex is made for, but is a wonderful way to save some
time and efforts.

Peter
Jul 18 '05 #4
Marc Schellens wrote:
ok, but why everybody writes #include "Python.h" instead of
#include <Python.h> ? The latter form is the corrcet one for
header files wich are not part of the actual project.


It's a minor point. The <...> notation is for system headers, the "..."
notation is for non-system headers, but will fall back to searching
system headers as well.

If it works at all -- and you haven't chosen deliberately conflicting
filenames -- then it doesn't matter which one you use.

--
__ Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ Sometimes we're blinded by the light / If we'd only use our eyes
-- Oleta Adams
Jul 18 '05 #5

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

Similar topics

2
by: disgracelands | last post by:
I've been looking at using python and it's been going fairly well so far, i can call C from python and python from C fine but now i've hit a snag and i'm wondering how you guys have got around it....
0
by: Stefan | last post by:
Hello, I've embedded Python in bigger application on a Debian system. Now I try to compile this application on Suse and find that the shared library libpython.so is not available. So I want to use...
11
by: Robert Ferber | last post by:
Hi, I'm a PHP-programmer who evaluates Python for a new project. I really like a lot of concepts of Python, especially the shell, but there is one great feature of PHP which I don't know how to...
0
by: kyo guan | last post by:
HI : I want to test my system's performance. My system has a python embed. How can I test the proformance like the python module "profile" or "hotshot" . I can't use the module "profile" because...
2
by: Wezzy | last post by:
Hi, is there a tool that automatically expose an object to python? i have an instance of a C++ (or ObjC) object and i want to pass it to the embed interpreter that runs inside my program. Python...
2
by: Lloyd | last post by:
Hi After researching on Extending and Embedding it appears Extending is favoured greatly over Embedding. I've tested Boost::Python successfully in a test project but have run into an issue. I...
6
by: qualitychecker | last post by:
Hello thanks for your help.. I try to reference a PHP module from within a HTML file, see below ---------------------------------------- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">...
7
by: Heiko Niedermeyer | last post by:
Sorry for the fuzzy subject... Currently I'm writing a little programm to extract some chemical information out of a text file, and then present it in a pleasant way. The Extraction works so...
5
by: elbin | last post by:
Hello, first to say that I am a total beginner in Javascript but I know some programming (python in particular) and am able to understand methods/parameters and so on. Here's my problem: I am...
1
by: oyster | last post by:
In my ms-word documnet, there are some calculation whihc I have to change due to different argumnet. is there any way to embed python code in word, so that I can write the following as a macro or...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.