Trouble including Python.h

M

Marcelo Gosling

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\include\", 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_PLT32
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
 
V

vduber6er

Try

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

or which ever path your python.h is located at

works for me
 
M

Marcelo Gosling

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
 
J

John Machin

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\include\", 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_PLT32
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
 
J

John Machin

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
 
T

Tim Roberts

Marcelo Gosling said:
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\include\", 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_PLT32
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top