developing managed c++ library

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Achim Domma (Procoders)

    #1

    developing managed c++ library

    Hi,

    I try to develop a .Net class library using managed c++ and have several
    problems:

    - If I use operator new, I get a linker error because operator new is
    missing. Searching the web I found out, that this is a well known
    problem which has to do with the initialization of the C/C++ runtime
    libraries. The proposed workaround looks not very promissing. But why
    would somebody use managed C++ is you could not use common C++ features?

    - I develop a library to work with AVI files. If I include windows.h and
    wfw.h in different source units, I get a linker error concerning
    metadata. Searching the web I found out that the reason seems to be,
    that structures with the same name are defined twice with differnt
    layout. How could this happen if I use standard include files?

    Could somebody help? At the moment, managed C++ makes no sense at all to me.

    regards,
    Achim
  • ismailp

    #2
    Re: developing managed c++ library

    Will this class library contain unmanaged code as well? If so, please
    read mixed mode DLLs on MSDN.

    Normally, you wouldn't get an error for new operator. I don't remember
    I have faced with a link failure with new operator.

    For the second problem, move windows.h into precompiled header file, or
    above the "#include <vfw.h>" line. It shouldn't be related to
    meta-data.

    What version of MC++ do you use?

    Ismail

    Comment

    • Achim Domma (Procoders)

      #3
      Re: developing managed c++ library

      ismailp wrote:
      [color=blue]
      > Will this class library contain unmanaged code as well? If so, please
      > read mixed mode DLLs on MSDN.[/color]

      Yes, it will contain unmanaged code. I have read the article on MSDN and
      I think I understood the problem.
      [color=blue]
      > Normally, you wouldn't get an error for new operator. I don't remember
      > I have faced with a link failure with new operator.[/color]

      I changed my code to use Windows functions to alloc/free memory. So
      operator new is no problem at the moment.
      [color=blue]
      > For the second problem, move windows.h into precompiled header file, or
      > above the "#include <vfw.h>" line. It shouldn't be related to
      > meta-data.[/color]

      I moved both files to stdafx.h and it works now. Still don't understand
      what the problem is. Do you know any good books about managed C++?
      [color=blue]
      > What version of MC++ do you use?[/color]

      I use the version which is part of Visual Studio 2003.

      Thanks for your fast answer.

      regards,
      Achim

      Comment

      • Ioannis Vranos

        #4
        Re: developing managed c++ library

        Achim Domma (Procoders) wrote:
        [color=blue]
        > I changed my code to use Windows functions to alloc/free memory. So
        > operator new is no problem at the moment.[/color]


        When using new for unmanaged types there should be no problem. Managed code and unmanaged
        code are two separate worlds.

        [color=blue]
        > I moved both files to stdafx.h and it works now. Still don't understand
        > what the problem is. Do you know any good books about managed C++?[/color]


        A good book is "Visual C++ .NET How To Program" by Deitel:


        Comment

        • ismailp

          #5
          Re: developing managed c++ library

          I have never encountered with such a problem with new/delete operators
          before.

          Having Windows.h at precompiled header or prior to other includes is
          "must" for some header files those do not include windows.h themselves.
          therefore, you need to include this before those headers in the
          translation unit. the best way is putting it into precompiled header.

          I think I have seen one book, it is MS-Press' but I couldn't recall its
          name. Please try to focus on C++/CLI rather than MC++. MC++ will be
          deprecated by C++/CLI.

          Ismail

          Comment

          • Achim Domma (Procoders)

            #6
            Re: developing managed c++ library

            ismailp wrote:
            [color=blue]
            > Having Windows.h at precompiled header or prior to other includes is
            > "must" for some header files those do not include windows.h themselves.
            > therefore, you need to include this before those headers in the
            > translation unit. the best way is putting it into precompiled header.[/color]

            I know that Vfw.h needs windows.h to be include first, so I had included
            windows.h already. But I included both files in two different cpp files,
            which seems to have caused the problem. Moving the includes to stdafx.h
            works fine.
            [color=blue]
            > I think I have seen one book, it is MS-Press' but I couldn't recall its
            > name.[/color]

            "Programmin g with Managed Extensions for Microsoft Visual C++ .NET
            Version 2003" by Richard Grimes looks promissing but is quite expensive.
            [color=blue]
            > Please try to focus on C++/CLI rather than MC++. MC++ will be
            > deprecated by C++/CLI.[/color]

            Don't know what you mean with C++/CLI and MC++ and what the difference
            is!? Is MC++ 'classic' C++ with raw pointers, STL and so on and C++/CLI
            is using the .Net framework?
            If that's true, I would not give up MC++, because I realy like STL,
            templates and so on. I implement low level algorithms and numeric stuff,
            which I would like to make available to other .Net languages.

            Currently I try to write a library to work with AVI Files. As already
            mentioned, I use the Windows Multimedia SDK to read the AVI Files. I
            have only seen C# interop examples which work with this API. An managing
            raw memory in C# seems to be a pain to me.

            How would you work with such raw C APIs?

            regards,
            Achim

            Comment

            • Ioannis Vranos

              #7
              Re: developing managed c++ library

              Achim Domma (Procoders) wrote:
              [color=blue]
              > Don't know what you mean with C++/CLI and MC++ and what the difference
              > is!? Is MC++ 'classic' C++ with raw pointers, STL and so on and C++/CLI
              > is using the .Net framework?[/color]


              C++/CLI is the descendant of "managed extensions" and will "replace and extend" them in VS
              2005.


              With VS 2005, C++ becomes the systems programming language of .NET.


              Some references:

              http://msdn.microsoft.com/msdnmag/is...s/default.aspx

              Expert-led tech and creative training to master your craft. Unlimited and online.


              http://blogs.msdn.com/branbray/archi.../07/51007.aspx




              And a page of mine:




              [color=blue]
              > If that's true, I would not give up MC++, because I realy like STL,
              > templates and so on. I implement low level algorithms and numeric stuff,
              > which I would like to make available to other .Net languages.[/color]


              VS 2005 will also provide an STL version that will also work for managed types.

              Comment

              • Ioannis Vranos

                #8
                Re: developing managed c++ library

                Ioannis Vranos wrote:
                [color=blue]
                > C++/CLI is the descendant of "managed extensions" and will "replace and
                > extend" them in VS 2005.[/color]


                In other words, we can say that it is "managed extensions version 2". Even the draft
                standard follows this as version numbering.

                Comment

                Working...