.cpp to .pyd

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vedrandekovic@yahoo.com

    .cpp to .pyd

    Hello,

    I want to build my C++ (.cpp) script to (.pyd) like this:



    I have installed "Microsoft Visual studio .NET 2003" and "Boost
    Python" and then after I run my setup script:

    python setup.py build


    I get this error:


    running build
    running build_ext
    building 'hello' extension
    D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl .exe /c /
    nologo /Ox
    /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\in clude -IC:
    \Panda3D-1.5.2\pytho
    n\PC /Tphellomodule.c pp /Fobuild\temp.wi n32-2.5\Release
    \hellomodule.ob j
    hellomodule.cpp
    hellomodule.cpp (9) : fatal error C1083: Cannot open include file:
    'boost/python/
    module.hpp': No such file or directory
    error: command '"D:\Program Files\Microsoft Visual Studio .NET
    2003\Vc7\bin\cl .e
    xe"' failed with exit status 2

    I think that my MS visual studio cannot find "boost python", if
    that's the problem then can you tell me how can I solve it.
    This is very begginer question,but I can't find answer nowhere, and I
    don't have any expirience with Microsoft products.


    Sorry for my bad english!
    Regards,
    Veki
  • Matthieu Brucher

    #2
    Re: .cpp to .pyd

    I think that my MS visual studio cannot find "boost python", if
    that's the problem then can you tell me how can I solve it.
    This is very begginer question,but I can't find answer nowhere, and I
    don't have any expirience with Microsoft products.
    Hi,

    Put Boost in your include path (options of Visual Studio).

    Matthieu
    --
    French PhD student
    Website : http://matthieu-brucher.developpez.com/
    Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
    LinkedIn : http://www.linkedin.com/in/matthieubrucher

    Comment

    • vedrandekovic@yahoo.com

      #3
      Re: .cpp to .pyd

      On 7 kol, 09:48, "Matthieu Brucher" <matthieu.bruc. ..@gmail.com>
      wrote:
      I think that my MS visual studio  cannot find "boost python", if
      that's the problem then can you tell me how can I solve it.
      This is very begginer question,but I can't find answer nowhere, and I
      don't have any expirience with Microsoft products.
      >
      Hi,
      >
      Put Boost in your include path (options of Visual Studio).
      >
      Matthieu
      --
      French PhD student
      Website :http://matthieu-brucher.developpez.com/
      Blogs :http://matt.eifelle.comandhttp://blo...z.com/?blog=92
      LinkedIn :http://www.linkedin.com/in/matthieubrucher
      Hello again,

      Thanks for your quick reply!
      Put Boost in your include path (options of Visual Studio).
      Look at my image:


      I still get the same error.

      Regards,
      Veki

      Comment

      • Ulrich Eckhardt

        #4
        Re: .cpp to .pyd

        vedrandekovic@y ahoo.com wrote:
        hellomodule.cpp (9) : fatal error C1083: Cannot open include file:
        'boost/python/module.hpp': No such file or directory
        You need to tell it where to find the Boost includes. I suggest you first
        try to get some header-only Boost library going as example, if you have
        that right, you also have the include paths right.

        In your second posting, you gave a link to a picture which had the exact
        right dialog for setting this as system setup. You can also set the path on
        a per-project base, then it's in the C++ settings.

        Note that for compiled libraries like Boost.Python you will first have to
        compile those (see Boost docs), put the DLLs into a place where they can be
        found (e.g. the windows dir or anything else on the path) and also have to
        set a path to the .LIBS in the linker settings.

        As an alternative to compiling libraries separately, you can also include
        the Boost sources into your project, just add BOOST_PYTHON_ST ATIC_LIB to
        the preprocessor defines and include the following files from one(!)
        translation unit:

        <boost/../libs/python/src/module.cpp>
        <boost/../libs/python/src/dict.cpp>
        <boost/../libs/python/src/errors.cpp>
        <boost/../libs/python/src/list.cpp>
        <boost/../libs/python/src/object_operator s.cpp>
        <boost/../libs/python/src/object_protocol .cpp>
        <boost/../libs/python/src/tuple.cpp>
        <boost/../libs/python/src/str.cpp>
        <boost/../libs/python/src/object/class.cpp>
        <boost/../libs/python/src/object/function.cpp>
        <boost/../libs/python/src/object/inheritance.cpp >
        <boost/../libs/python/src/object/pickle_support. cpp>
        <boost/../libs/python/src/converter/builtin_convert ers.cpp>
        <boost/../libs/python/src/converter/registry.cpp>
        <boost/../libs/python/src/converter/from_python.cpp >

        Note: this is with Boost 1.33.1, newer versions likely differ.


        Uli

        --
        Sator Laser GmbH
        Geschäftsführ er: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

        Comment

        • Kay Schluehr

          #5
          Re: .cpp to .pyd

          It doesn't look like a VS issue since you've started the setup.py
          script that calls the command line compiler. So I'd expect it behaves
          not different from other command line tools and you might have to add
          the boost path directly to the command-line options.

          Comment

          • vedrandekovic@yahoo.com

            #6
            Re: .cpp to .pyd

            On 7 kol, 11:37, Ulrich Eckhardt <eckha...@sator laser.comwrote:
            vedrandeko...@y ahoo.com wrote:
            hellomodule.cpp (9) : fatal error C1083: Cannot open include file:
            'boost/python/module.hpp': No such file or directory
            >
            You need to tell it where to find the Boost includes. I suggest you first
            try to get some header-only Boost library going as example, if you have
            that right, you also have the include paths right.
            >
            In your second posting, you gave a link to a picture which had the exact
            right dialog for setting this as system setup. You can also set the path on
            a per-project base, then it's in the C++ settings.
            >
            Note that for compiled libraries like Boost.Python you will first have to
            compile those (see Boost docs), put the DLLs into a place where they can be
            found (e.g. the windows dir or anything else on the path) and also have to
            set a path to the .LIBS in the linker settings.
            >
            As an alternative to compiling libraries separately, you can also include
            the Boost sources into your project, just add BOOST_PYTHON_ST ATIC_LIB to
            the preprocessor defines and include the following files from one(!)
            translation unit:
            >
            <boost/../libs/python/src/module.cpp>
            <boost/../libs/python/src/dict.cpp>
            <boost/../libs/python/src/errors.cpp>
            <boost/../libs/python/src/list.cpp>
            <boost/../libs/python/src/object_operator s.cpp>
            <boost/../libs/python/src/object_protocol .cpp>
            <boost/../libs/python/src/tuple.cpp>
            <boost/../libs/python/src/str.cpp>
            <boost/../libs/python/src/object/class.cpp>
            <boost/../libs/python/src/object/function.cpp>
            <boost/../libs/python/src/object/inheritance.cpp >
            <boost/../libs/python/src/object/pickle_support. cpp>
            <boost/../libs/python/src/converter/builtin_convert ers.cpp>
            <boost/../libs/python/src/converter/registry.cpp>
            <boost/../libs/python/src/converter/from_python.cpp >
            >
            Note: this is with Boost 1.33.1, newer versions likely differ.
            >
            Uli
            >
            --
            Sator Laser GmbH
            Geschäftsführer : Thorsten Föcking, Amtsgericht Hamburg HR B62 932
            Hello again,

            This answer is probably exactly what I need, but as I said, I don't
            have any expirience with MS products! Is there any other easier
            way except "boost python" to make .pyd from .cpp?

            Comment

            • Carl Banks

              #7
              Re: .cpp to .pyd

              On Aug 7, 3:25 am, vedrandeko...@y ahoo.com wrote:
              Hello,
              >
              I want to build my C++ (.cpp) script to (.pyd) like this:
              >

              >
              I have installed "Microsoft Visual studio .NET 2003" and "Boost
              Python" and then after I run my setup script:
              >
              python setup.py build
              >
              I get this error:
              >
              running build
              running build_ext
              building 'hello' extension
              D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl .exe /c /
              nologo /Ox
               /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\in clude -IC:
              \Panda3D-1.5.2\pytho
              n\PC /Tphellomodule.c pp /Fobuild\temp.wi n32-2.5\Release
              \hellomodule.ob j
              hellomodule.cpp
              hellomodule.cpp (9) : fatal error C1083: Cannot open include file:
              'boost/python/
              module.hpp': No such file or directory
              error: command '"D:\Program Files\Microsoft Visual Studio .NET
              2003\Vc7\bin\cl .e
              xe"' failed with exit status 2
              >
              I think that my MS visual studio  cannot find "boost python", if
              that's the problem then can you tell me how can I solve it.
              This is very begginer question,but I can't find answer nowhere, and I
              don't have any expirience with Microsoft products.
              >
              Sorry for my bad english!
              Regards,
              Veki

              First, locate the boost header files. Suppose you find the file
              module.hpp in this location:

              C:\boost-whatever-version\include \boost\python\m odule.hpp


              The part that comes before boost\python\mo dule.hpp is the required
              include directory. You can tell setup to use this directory by adding
              the following argument to the Extension call:

              include_dirs = ['C:\\boost-whatever-version\\includ e']

              Notice the doubling of backslashes. Remember to add the directory
              where the boost header files lie on your system; don't add this line
              exactly.

              You should end up with a setup call that looks like this:

              setup(name="bla h",
              ext_modules=[
              Extension("hell o", ["hellomodule.cp p"],
              libraries = ["boost_pyth on"],
              include_dirs = ['C:\\boost-whatever-version\\includ e'])
              ])



              Carl Banks

              Comment

              • Kay Schluehr

                #8
                Re: .cpp to .pyd

                On 7 Aug., 21:43, Carl Banks <pavlovevide... @gmail.comwrote :
                On Aug 7, 3:25 am, vedrandeko...@y ahoo.com wrote:
                >
                >
                >
                Hello,
                >
                I want to build my C++ (.cpp) script to (.pyd) like this:
                >>
                I have installed "Microsoft Visual studio .NET 2003" and "Boost
                Python" and then after I run my setup script:
                >
                python setup.py build
                >
                I get this error:
                >
                running build
                running build_ext
                building 'hello' extension
                D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl .exe /c /
                nologo /Ox
                /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\in clude -IC:
                \Panda3D-1.5.2\pytho
                n\PC /Tphellomodule.c pp /Fobuild\temp.wi n32-2.5\Release
                \hellomodule.ob j
                hellomodule.cpp
                hellomodule.cpp (9) : fatal error C1083: Cannot open include file:
                'boost/python/
                module.hpp': No such file or directory
                error: command '"D:\Program Files\Microsoft Visual Studio .NET
                2003\Vc7\bin\cl .e
                xe"' failed with exit status 2
                >
                I think that my MS visual studio cannot find "boost python", if
                that's the problem then can you tell me how can I solve it.
                This is very begginer question,but I can't find answer nowhere, and I
                don't have any expirience with Microsoft products.
                >
                Sorry for my bad english!
                Regards,
                Veki
                >
                First, locate the boost header files. Suppose you find the file
                module.hpp in this location:
                >
                C:\boost-whatever-version\include \boost\python\m odule.hpp
                >
                The part that comes before boost\python\mo dule.hpp is the required
                include directory. You can tell setup to use this directory by adding
                the following argument to the Extension call:
                >
                include_dirs = ['C:\\boost-whatever-version\\includ e']
                >
                Notice the doubling of backslashes. Remember to add the directory
                where the boost header files lie on your system; don't add this line
                exactly.
                >
                You should end up with a setup call that looks like this:
                >
                setup(name="bla h",
                ext_modules=[
                Extension("hell o", ["hellomodule.cp p"],
                libraries = ["boost_pyth on"],
                include_dirs = ['C:\\boost-whatever-version\\includ e'])
                ])
                >
                Carl Banks
                One can omit double backslashes when prefixing by 'r' or 'R':

                r'C:\boost-whatever-version\include '

                Python is just too kind.

                Comment

                • vedrandekovic@yahoo.com

                  #9
                  Re: .cpp to .pyd

                  On 7 kol, 21:43, Carl Banks <pavlovevide... @gmail.comwrote :
                  On Aug 7, 3:25 am, vedrandeko...@y ahoo.com wrote:
                  >
                  >
                  >
                  Hello,
                  >
                  I want to build my C++ (.cpp) script to (.pyd) like this:
                  >>
                  I have installed "Microsoft Visual studio .NET 2003" and "Boost
                  Python" and then after I run my setup script:
                  >
                  python setup.py build
                  >
                  I get this error:
                  >
                  running build
                  running build_ext
                  building 'hello' extension
                  D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl .exe /c /
                  nologo /Ox
                   /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\in clude -IC:
                  \Panda3D-1.5.2\pytho
                  n\PC /Tphellomodule.c pp /Fobuild\temp.wi n32-2.5\Release
                  \hellomodule.ob j
                  hellomodule.cpp
                  hellomodule.cpp (9) : fatal error C1083: Cannot open include file:
                  'boost/python/
                  module.hpp': No such file or directory
                  error: command '"D:\Program Files\Microsoft Visual Studio .NET
                  2003\Vc7\bin\cl .e
                  xe"' failed with exit status 2
                  >
                  I think that my MS visual studio  cannot find "boost python", if
                  that's the problem then can you tell me how can I solve it.
                  This is very begginer question,but I can't find answer nowhere, and I
                  don't have any expirience with Microsoft products.
                  >
                  Sorry for my bad english!
                  Regards,
                  Veki
                  >
                  First, locate the boost header files.  Suppose you find the file
                  module.hpp in this location:
                  >
                  C:\boost-whatever-version\include \boost\python\m odule.hpp
                  >
                  The part that comes before boost\python\mo dule.hpp is the required
                  include directory.  You can tell setup to use this directory by adding
                  the following argument to the Extension call:
                  >
                  include_dirs = ['C:\\boost-whatever-version\\includ e']
                  >
                  Notice the doubling of backslashes.  Remember to add the directory
                  where the boost header files lie on your system; don't add this line
                  exactly.
                  >
                  You should end up with a setup call that looks like this:
                  >
                  setup(name="bla h",
                      ext_modules=[
                          Extension("hell o", ["hellomodule.cp p"],
                              libraries = ["boost_pyth on"],
                              include_dirs = ['C:\\boost-whatever-version\\includ e'])
                      ])
                  >
                  Carl Banks
                  Hi,

                  Thanks for quick reply.Maybe I'm crazy but I did what you said and I
                  stll get the same error :( :( :( :(.I have boost version 1.34.1 and
                  I'm
                  running it on Windows XP SP2.

                  Regards,
                  Veki

                  Comment

                  • Carl Banks

                    #10
                    Re: .cpp to .pyd

                    On Aug 8, 1:11 pm, vedrandeko...@y ahoo.com wrote:
                    Thanks for quick reply.Maybe I'm crazy but I did what you said and I
                    stll get the same error :(  :(  :( :(.I have boost version 1.34.1 and
                    I'm
                    running it on Windows XP SP2.

                    If you had done what I said you wouldn't have gotten the "same error";
                    if nothing else there would be some small changes in the output that
                    could give us a better understanding of what's wrong.

                    So even if it is the same error message, unless you know for a fact
                    that every last byte of output is exactly the same, please post it.


                    Carl Banks

                    Comment

                    • Carl Banks

                      #11
                      Re: .cpp to .pyd

                      On Aug 8, 1:11 pm, vedrandeko...@y ahoo.com wrote:
                      Thanks for quick reply.Maybe I'm crazy but I did what you said and I
                      stll get the same error :(  :(  :( :(.I have boost version 1.34.1 and
                      I'm
                      running it on Windows XP SP2.
                      While you're at it, please post your setup.py

                      Carl Banks

                      Comment

                      • vedrandekovic@yahoo.com

                        #12
                        Re: .cpp to .pyd

                        On 9 kol, 01:27, Carl Banks <pavlovevide... @gmail.comwrote :
                        On Aug 8, 1:11 pm, vedrandeko...@y ahoo.com wrote:
                        >
                        Thanks for quick reply.Maybe I'm crazy but I did what you said and I
                        stll get the same error :(  :(  :( :(.I have boost version 1.34.1 and
                        I'm
                        running it on Windows XP SP2.
                        >
                        While you're at it, please post your setup.py
                        >
                        Carl Banks
                        Hi,

                        Here is my setup.py script:

                        setup(name="MyA pp",
                        ext_modules=[
                        Extension("hell o", ["hellomodule.cp p"],
                        libraries = ["boost_pyth on"],
                        include_dirs = ['D:\\Program Files\\boost\\b oost_1_34_1\
                        \boost'],
                        )
                        ])

                        Regards,
                        Veki

                        Comment

                        • vedrandekovic@yahoo.com

                          #13
                          Re: .cpp to .pyd

                          On 9 kol, 13:34, vedrandeko...@y ahoo.com wrote:
                          On 9 kol, 01:27, Carl Banks <pavlovevide... @gmail.comwrote :
                          >
                          On Aug 8, 1:11 pm, vedrandeko...@y ahoo.com wrote:
                          >
                          Thanks for quick reply.Maybe I'm crazy but I did what you said and I
                          stll get the same error :(  :(  :( :(.I have boost version 1.34.1and
                          I'm
                          running it on Windows XP SP2.
                          >
                          While you're at it, please post your setup.py
                          >
                          Carl Banks
                          >
                          Hi,
                          >
                          Here is my setup.py script:
                          >
                          setup(name="MyA pp",
                              ext_modules=[
                                  Extension("hell o", ["hellomodule.cp p"],
                                      libraries = ["boost_pyth on"],
                                      include_dirs = ['D:\\Program Files\\boost\\b oost_1_34_1\
                          \boost'],
                                      )
                              ])
                          >
                          Regards,
                          Veki
                          Hello,

                          ...and here is the error:

                          C:\Panda3D-1.5.2\python\Li b\site-packages>python setup.py build
                          running build
                          running build_ext
                          building 'hello' extension
                          D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl .exe /c /
                          nologo /Ox
                          /MD /W3 /GX /DNDEBUG "-ID:\Program Files\boost\boo st_1_34_1\boost " -
                          IC:\Panda3D
                          -1.5.2\python\in clude -IC:\Panda3D-1.5.2\python\PC /Tphellomodule.c pp /
                          Fobuild\t
                          emp.win32-2.5\Release\hel lomodule.obj
                          hellomodule.cpp
                          hellomodule.cpp (9) : fatal error C1083: Cannot open include file:
                          'boost/python/
                          module.hpp': No such file or directory
                          error: command '"D:\Program Files\Microsoft Visual Studio .NET
                          2003\Vc7\bin\cl .e
                          xe"' failed with exit status 2

                          C:\Panda3D-1.5.2\python\Li b\site-packages>pause
                          Press any key to continue . . .

                          Comment

                          • Carl Banks

                            #14
                            Re: .cpp to .pyd

                            On Aug 9, 7:46 am, vedrandeko...@y ahoo.com wrote:
                            On 9 kol, 13:34, vedrandeko...@y ahoo.com wrote:
                            >
                            >
                            >
                            On 9 kol, 01:27, Carl Banks <pavlovevide... @gmail.comwrote :
                            >
                            On Aug 8, 1:11 pm, vedrandeko...@y ahoo.com wrote:
                            >
                            Thanks for quick reply.Maybe I'm crazy but I did what you said and I
                            stll get the same error :(  :(  :( :(.I have boost version 1.34..1 and
                            I'm
                            running it on Windows XP SP2.
                            >
                            While you're at it, please post your setup.py
                            >
                            Carl Banks
                            >
                            Hi,
                            >
                            Here is my setup.py script:
                            >
                            setup(name="MyA pp",
                                ext_modules=[
                                    Extension("hell o", ["hellomodule.cp p"],
                                        libraries = ["boost_pyth on"],
                                        include_dirs = ['D:\\Program Files\\boost\\b oost_1_34_1\
                            \boost'],
                                        )
                                ])
                            >
                            Regards,
                            Veki
                            >
                            Hello,
                            >
                            ...and here is the error:
                            >
                            C:\Panda3D-1.5.2\python\Li b\site-packages>python setup.py build
                            running build
                            running build_ext
                            building 'hello' extension
                            D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl .exe /c /
                            nologo /Ox
                             /MD /W3 /GX /DNDEBUG "-ID:\Program Files\boost\boo st_1_34_1\boost " -
                            Good, it's included the directory you specified.
                            IC:\Panda3D
                            -1.5.2\python\in clude -IC:\Panda3D-1.5.2\python\PC /Tphellomodule.c pp /
                            Fobuild\t
                            emp.win32-2.5\Release\hel lomodule.obj
                            hellomodule.cpp
                            hellomodule.cpp (9) : fatal error C1083: Cannot open include file:
                            'boost/python/
                            module.hpp': No such file or directory
                            But the file is not located there.
                            error: command '"D:\Program Files\Microsoft Visual Studio .NET
                            2003\Vc7\bin\cl .e
                            xe"' failed with exit status 2
                            >
                            C:\Panda3D-1.5.2\python\Li b\site-packages>pause
                            Press any key to continue . . .
                            Ok, you have your include directory:

                            D:\Program Files\boost\boo st_1_34_1\boost

                            And the file it's trying to access:

                            boost\python\mo dule.hpp

                            The compiler tries to join the two when searching for the file to
                            include, like so:

                            D:\Program Files\boost\boo st_1_34_1\boost \boost\python\m odule.hpp

                            Does this file exist on your system? Probably not. What you probably
                            did was to include the top boost directory in your setup.py when you
                            should have left it out like this:

                            include_dirs = ['D:\\Program Files\\boost\\b oost_1_34_1']

                            If that doesn't work, find the file "module.hpp ", take the complete
                            pathname, remove the boost\python\mo dule.hpp part, and use that as the
                            include_dir.


                            Carl Banks

                            Comment

                            Working...