Trouble including Python.h

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcelo Gosling

    #1

    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

  • vduber6er

    #2
    Re: Trouble including Python.h

    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:[color=blue]
    > 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[/color]

    Comment

    • Marcelo Gosling

      #3
      Re: Trouble including Python.h

      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:[color=blue]
      > 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:[color=green]
      > > 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[/color][/color]

      Comment

      • John Machin

        #4
        Re: Trouble including Python.h

        On 24/06/2006 7:51 AM, Marcelo Gosling wrote:[color=blue]
        > 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[/color]

        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????
        [color=blue]
        > 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:[/color]

        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


        Comment

        • John Machin

          #5
          Re: Trouble including Python.h

          On 24/06/2006 12:14 PM, John Machin wrote:[color=blue]
          > On 24/06/2006 7:51 AM, Marcelo Gosling wrote:[color=green]
          >> I'm having trouble including Python.h in a C file. The following C
          >> code:[/color][/color]
          [color=blue][color=green]
          >> In file included from ../../Python2.4/include/Python.h:74,
          >> from example_wrap.c: 112:[/color]
          >
          > 1. You allegedly have a 6-line test program. What is this example_wrap.c
          > that has 112 lines (or more) in it?[/color]

          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

          Comment

          • Tim Roberts

            #6
            Re: Trouble including Python.h

            "Marcelo Gosling" <marcelo.goslin g@gmail.com> wrote:[color=blue]
            >
            >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'[/color]

            __declspec is a Microsoft extension. Are you trying to build the Visual
            C++ source with gcc?
            --
            - Tim Roberts, timr@probo.com
            Providenza & Boekelheide, Inc.

            Comment

            Working...