Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Trouble including Python.h

Reply
Thread Tools

Trouble including Python.h

 
 
Marcelo Gosling
Guest
Posts: n/a
 
      06-23-2006
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

 
Reply With Quote
 
 
 
 
vduber6er
Guest
Posts: n/a
 
      06-23-2006
Try

#undef _DEBUG
#include "C:\Python24\include\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\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


 
Reply With Quote
 
 
 
 
Marcelo Gosling
Guest
Posts: n/a
 
      06-23-2006
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\include\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\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


 
Reply With Quote
 
John Machin
Guest
Posts: n/a
 
      06-24-2006
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\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


 
Reply With Quote
 
John Machin
Guest
Posts: n/a
 
      06-24-2006
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

 
Reply With Quote
 
Tim Roberts
Guest
Posts: n/a
 
      06-24-2006
"Marcelo Gosling" <(E-Mail Removed)> 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\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?
--
- Tim Roberts, http://www.velocityreviews.com/forums/(E-Mail Removed)
Providenza & Boekelheide, Inc.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: trouble including css into the html Adrienne Boswell HTML 0 05-10-2010 01:52 PM
Re: trouble including css into the html Beauregard T. Shagnasty HTML 0 05-10-2010 01:17 PM
i have no trouble to send , ihave trouble reciving mail --any ideas John Penney Computer Support 4 08-29-2006 08:45 PM
trouble including "iostream" "fstream" NewToCPP C++ 2 01-17-2006 10:33 PM
trouble with caching or caching the trouble Hypo ASP .Net 6 08-01-2003 07:11 AM



Advertisments