473,657 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble including Python.h

Hi, everyone.

This is on WinXP SP2, with Python 2.4.3 and DJGPP gcc 4.1.0.

I'm having trouble including Python.h in a C file. The following C
code:

#include "Python.h"

int main()
{
return 0;
}

when compiled with "gcc -I..\Python2.4\i nclude\", gives more than 1000
lines of errors, beginning with:

c:/documents and settings/marcelo.gosling/my
documents/djgpp/bin/as.exe: BFD 2.16.1 assertion fail
.../../bfd/coff-i386.c:576
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s: Assembler messages:
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s:28: Error: cannot represent relocation
type BFD_RELOC_386_P LT32
In file included from ../../Python2.4/include/Python.h:74,
from example_wrap.c: 112:
.../../Python2.4/include/pymem.h: In function '__declspec':
.../../Python2.4/include/pymem.h:51: error: expected declaration
specifiers before '__declspec'
.../../Python2.4/include/pymem.h:52: error: expected declaration
specifiers before '__declspec'
In file included from ../../Python2.4/include/Python.h:76,
from example_wrap.c: 112:
.../../Python2.4/include/object.h:104: error: storage class specified
for parameter 'PyObject'
.../../Python2.4/include/object.h:108: error: storage class specified
for parameter 'PyVarObject'
.../../Python2.4/include/object.h:126: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
.../../Python2.4/include/object.h:127: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
.../../Python2.4/include/object.h:128: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
.../../Python2.4/include/object.h:129: error: expected ')' before '*'
token
.../../Python2.4/include/object.h:130: error: expected ')' before '*'
token

Am I missing something important here?

Thanks in advance,

Marcelo

Jun 23 '06 #1
5 1991
Try

#undef _DEBUG
#include "C:\Python24\in clude\python.h"

or which ever path your python.h is located at

works for me

Marcelo Gosling wrote:
Hi, everyone.

This is on WinXP SP2, with Python 2.4.3 and DJGPP gcc 4.1.0.

I'm having trouble including Python.h in a C file. The following C
code:

#include "Python.h"

int main()
{
return 0;
}

when compiled with "gcc -I..\Python2.4\i nclude\", gives more than 1000
lines of errors, beginning with:

c:/documents and settings/marcelo.gosling/my
documents/djgpp/bin/as.exe: BFD 2.16.1 assertion fail
../../bfd/coff-i386.c:576
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s: Assembler messages:
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s:28: Error: cannot represent relocation
type BFD_RELOC_386_P LT32
In file included from ../../Python2.4/include/Python.h:74,
from example_wrap.c: 112:
../../Python2.4/include/pymem.h: In function '__declspec':
../../Python2.4/include/pymem.h:51: error: expected declaration
specifiers before '__declspec'
../../Python2.4/include/pymem.h:52: error: expected declaration
specifiers before '__declspec'
In file included from ../../Python2.4/include/Python.h:76,
from example_wrap.c: 112:
../../Python2.4/include/object.h:104: error: storage class specified
for parameter 'PyObject'
../../Python2.4/include/object.h:108: error: storage class specified
for parameter 'PyVarObject'
../../Python2.4/include/object.h:126: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
../../Python2.4/include/object.h:127: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
../../Python2.4/include/object.h:128: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
../../Python2.4/include/object.h:129: error: expected ')' before '*'
token
../../Python2.4/include/object.h:130: error: expected ')' before '*'
token

Am I missing something important here?

Thanks in advance,

Marcelo


Jun 23 '06 #2
No, that didn't do the trick. The main reason I'm posting this here is
that I get all tese error messages just from including Python.h, the
code itself does absolutely nothing.

Cheers

vduber6er wrote:
Try

#undef _DEBUG
#include "C:\Python24\in clude\python.h"

or which ever path your python.h is located at

works for me

Marcelo Gosling wrote:
Hi, everyone.

This is on WinXP SP2, with Python 2.4.3 and DJGPP gcc 4.1.0.

I'm having trouble including Python.h in a C file. The following C
code:

#include "Python.h"

int main()
{
return 0;
}

when compiled with "gcc -I..\Python2.4\i nclude\", gives more than 1000
lines of errors, beginning with:

c:/documents and settings/marcelo.gosling/my
documents/djgpp/bin/as.exe: BFD 2.16.1 assertion fail
../../bfd/coff-i386.c:576
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s: Assembler messages:
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s:28: Error: cannot represent relocation
type BFD_RELOC_386_P LT32
In file included from ../../Python2.4/include/Python.h:74,
from example_wrap.c: 112:
../../Python2.4/include/pymem.h: In function '__declspec':
../../Python2.4/include/pymem.h:51: error: expected declaration
specifiers before '__declspec'
../../Python2.4/include/pymem.h:52: error: expected declaration
specifiers before '__declspec'
In file included from ../../Python2.4/include/Python.h:76,
from example_wrap.c: 112:
../../Python2.4/include/object.h:104: error: storage class specified
for parameter 'PyObject'
../../Python2.4/include/object.h:108: error: storage class specified
for parameter 'PyVarObject'
../../Python2.4/include/object.h:126: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
../../Python2.4/include/object.h:127: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
../../Python2.4/include/object.h:128: error: expected '=', ',', ';',
'asm' or '__attribute__' before '*' token
../../Python2.4/include/object.h:129: error: expected ')' before '*'
token
../../Python2.4/include/object.h:130: error: expected ')' before '*'
token

Am I missing something important here?

Thanks in advance,

Marcelo


Jun 23 '06 #3
On 24/06/2006 7:51 AM, Marcelo Gosling wrote:
Hi, everyone.

This is on WinXP SP2, with Python 2.4.3 and DJGPP gcc 4.1.0.

I'm having trouble including Python.h in a C file. The following C
code:

#include "Python.h"

int main()
{
return 0;
}

when compiled with "gcc -I..\Python2.4\i nclude\", gives more than 1000
lines of errors, beginning with:

c:/documents and settings/marcelo.gosling/my
documents/djgpp/bin/as.exe: BFD 2.16.1 assertion fail
../../bfd/coff-i386.c:576
Hmmmm.... the *assembler* appears to be grumbling about its input. I'd
suspect that you have a mangled DJGPP installation. You may be better
asking on the DJGPP mailing list.

Aside: Wouldn't it have been better to install DJGPP in c:\djgpp????
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s: Assembler messages:
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s:28: Error: cannot represent relocation
type BFD_RELOC_386_P LT32
In file included from ../../Python2.4/include/Python.h:74,
from example_wrap.c: 112:


1. You allegedly have a 6-line test program. What is this example_wrap.c
that has 112 lines (or more) in it?
2. What was the full compiler command line?
3. What are you doing with DJGPP? Are you attempting to make an MS-DOS
port of Python?
4. Have you successfully compiled linked and executed anything with this
installation of DJGPP? Does the standard "Hello, world!" program work?
5. Have you tried compiling (not linking) this:

#include "Python.h"
void dummy() {}

HTH,
John
Jun 24 '06 #4
On 24/06/2006 12:14 PM, John Machin wrote:
On 24/06/2006 7:51 AM, Marcelo Gosling wrote:
I'm having trouble including Python.h in a C file. The following C
code: In file included from ../../Python2.4/include/Python.h:74,
from example_wrap.c: 112:


1. You allegedly have a 6-line test program. What is this example_wrap.c
that has 112 lines (or more) in it?


If you're trying to use SWIG (which could quite plausibly have created
an example_wrap.c from an example.c), wouldn't you be better off with
MinGW??????

I suggest you back away from your 1000-error-message train smash and try
telling us what you are trying to accomplish and a little bit more of
the history of how you got on this path.

Cheers,
John

Jun 24 '06 #5
"Marcelo Gosling" <ma************ *@gmail.com> wrote:

Hi, everyone.

This is on WinXP SP2, with Python 2.4.3 and DJGPP gcc 4.1.0.

I'm having trouble including Python.h in a C file. The following C
code:

#include "Python.h"

int main()
{
return 0;
}

when compiled with "gcc -I..\Python2.4\i nclude\", gives more than 1000
lines of errors, beginning with:

c:/documents and settings/marcelo.gosling/my
documents/djgpp/bin/as.exe: BFD 2.16.1 assertion fail
../../bfd/coff-i386.c:576
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s: Assembler messages:
c:/documents and settings/marcelo.gosling/my
documents/djgpp/tmp/ccACtxBR.s:28: Error: cannot represent relocation
type BFD_RELOC_386_P LT32
In file included from ../../Python2.4/include/Python.h:74,
from example_wrap.c: 112:
../../Python2.4/include/pymem.h: In function '__declspec':
../../Python2.4/include/pymem.h:51: error: expected declaration
specifiers before '__declspec'
../../Python2.4/include/pymem.h:52: error: expected declaration
specifiers before '__declspec'


__declspec is a Microsoft extension. Are you trying to build the Visual
C++ source with gcc?
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 24 '06 #6

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

Similar topics

9
4950
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
4
2489
by: J Rice | last post by:
I have been experimenting with some thread programming, but as I'm doing this on my own I am worried I might be making a major mistake. Here's a brief rundown of what I am working on. Multiple threads, via Queue, are used to perform RBL checks on an IP. The threads are passed a defined class (ConnectionScore) in their init. This is used to collect the results, including a method to add the result. If I run the program, everything...
6
2254
by: Gonzalo Monzón | last post by:
Hi all! I have been translating some Python custom C extension code into Python, as I need these modules to be portable and run on a PocketPC without the need of compile (for the purpose its a must 2.4 as it is the last PythonCE release with great improvements). But I've been stuck with a script wich does not work as expected once translated to python, 2.4
7
1822
by: f pemberton | last post by:
I have a string (xdata) and theres a newline after every 17 characters of the string. I was wondering how I can replace multiple substrings multiple times within a string? To put it another way, this is what i want to do. Substring to find ("abcdef") replace it with ("highway") search again, substring to find ("defgef") replace it with ("news").Search again and find ("effwer") replace it with ("monitor").Example string to search under...
8
1175
by: John Salerno | last post by:
I was just thinking, since Python 3.0 is supposed to clean up a lot of the unnecessary or redundant features of Python and make other things more streamlined, does it seem to anyone that including SQLite goes against this goal? This is just me thinking out loud, mind you, but it seems like including a database module (especially one that many people won't use in favor of MySQL or PostgreSQL, etc.) is weighing down the standard library. I...
5
3493
by: tkondal | last post by:
Hi all. I just started looking at Python's ctypes lib and I am having trouble using it for a function. For starters, here's my Python code: from ctypes import*; myStringDLL= cdll.LoadLibrary("myStringDLL.dll");
3
4536
by: sab | last post by:
Hello, I have been working on a python script to parse a continuously growing log file on a UNIX server. The input is the standard in, piped in from the log file. The application works well for the most part, but the problem is when attempting to continuously pipe information into the application via the tail -f command. The command line looks something like this: tail -f <logfile| grep <search string| python parse.py
0
1335
by: Basha J P M | last post by:
I am beginner in python. I am working through the tutorial examples from http://www.swig.org/ and have run into some problems. I took the following command instructions from the tutorial on swig.org: http://www.swig.org/tutorial.html I have written example.c and example.i as described in the above tutorial. My first attempt at compiling the libraries was this:
8
1678
by: J Kenneth King | last post by:
Hey everyone, I'm working on a python extension wrapper around Rob Hess' implementation of a SIFT feature detector. I'm working on a computer-vision based project that requires interfacing with Python at the higher layers, so I figured the best way to handle this would be in C (since my initial implementation in python was ungodly and slow). I can get distutils to compile the extension and install it in the python path, but when I go...
0
8316
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8509
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5636
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2735
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
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.