Trouble including Python.h

Discussion in 'Python' started by Marcelo Gosling, Jun 23, 2006.

  1. 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
     
    Marcelo Gosling, Jun 23, 2006
    #1
    1. Advertising

  2. Marcelo Gosling

    vduber6er Guest

    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
     
    vduber6er, Jun 23, 2006
    #2
    1. Advertising

  3. 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
     
    Marcelo Gosling, Jun 23, 2006
    #3
  4. Marcelo Gosling

    John Machin Guest

    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
     
    John Machin, Jun 24, 2006
    #4
  5. Marcelo Gosling

    John Machin Guest

    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
     
    John Machin, Jun 24, 2006
    #5
  6. Marcelo Gosling

    Tim Roberts Guest

    "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'


    __declspec is a Microsoft extension. Are you trying to build the Visual
    C++ source with gcc?
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
     
    Tim Roberts, Jun 24, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hypo
    Replies:
    6
    Views:
    454
  2. Tim Fuehner
    Replies:
    0
    Views:
    408
    Tim Fuehner
    Dec 8, 2003
  3. NewToCPP
    Replies:
    2
    Views:
    542
    Victor Bazarov
    Jan 17, 2006
  4. Beauregard T. Shagnasty

    Re: trouble including css into the html

    Beauregard T. Shagnasty, May 10, 2010, in forum: HTML
    Replies:
    0
    Views:
    431
    Beauregard T. Shagnasty
    May 10, 2010
  5. Adrienne Boswell

    Re: trouble including css into the html

    Adrienne Boswell, May 10, 2010, in forum: HTML
    Replies:
    0
    Views:
    429
    Adrienne Boswell
    May 10, 2010
Loading...

Share This Page