mscorlib.dll problem (Visual C++ 2005)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Hardin

    mscorlib.dll problem (Visual C++ 2005)

    Hey,
    I just downloaded Visual C++ 2005 Express, and I'm reading through a
    book called "Visual C++ .NET Step By Step", which was made for 2003.
    Just so you know where I'm getting this example.

    When I build this code, I get the following compile error.

    1>c:\documents and settings\editin g\my
    documents\alex\ c++\animal\anim al\animal.cpp(6 ) : fatal error C1190:
    managed targeted code requires a '/clr' option

    And that is regarding this:

    #using <mscorlib.dll >

    And then when I had /clr to the options, it then says:

    1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line
    options are incompatible

    So if I shut off /RTC1 in code generation, then it just says that
    therer is another thing incompatible (/Gm I think) and it just keeps
    going on with incompatibiliti es. Is there any way that I can make this
    code work?

    ////////////////////////////////////////////////////////////////////////

    // Animal.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"

    #using <mscorlib.dll >

    using namespace System;

    __gc class Animal
    {
    public:
    int legs;
    void SetName(String *name)
    { strName = strName->Copy(name); }
    String* GetName() { return strName; }
    private:
    String *strName;
    };


    int _tmain()
    {
    Animal *cat, *dog;
    cat = new Animal;
    dog = new Animal;

    cat->SetName("Cat") ;
    cat->legs = 4;
    dog->SetName("Dog") ;
    dog->legs = 4;

    Console::WriteL ine("Animal 1");
    Console::Write( "Name: ");
    Console::WriteL ine(cat->GetName());
    Console::Write( "Legs: ");
    Console::Write( cat->legs);

    return 0;
    }

    //////////////////////////////////////////////////////

    I am using a regular Win32 console applications. Thanks alot.

  • Jacek Dziedzic

    #2
    Re: mscorlib.dll problem (Visual C++ 2005)

    Alex Hardin wrote:[color=blue]
    > Hey,
    > I just downloaded Visual C++ 2005 Express, and I'm reading through a
    > book called "Visual C++ .NET Step By Step", which was made for 2003.
    > Just so you know where I'm getting this example.[/color]



    HTH,
    - J.

    Comment

    • John Carson

      #3
      Re: mscorlib.dll problem (Visual C++ 2005)

      "Alex Hardin" <619southtown@g mail.com> wrote in message
      news:1134853904 .270905.281640@ g47g2000cwa.goo glegroups.com[color=blue]
      > Hey,
      > I just downloaded Visual C++ 2005 Express, and I'm reading through a
      > book called "Visual C++ .NET Step By Step",[/color]

      Judging by the reviews on Amazon, it is a dreadful book.
      [color=blue]
      > which was made for 2003.
      > Just so you know where I'm getting this example.
      > When I build this code, I get the following compile error.
      >
      > 1>c:\documents and settings\editin g\my
      > documents\alex\ c++\animal\anim al\animal.cpp(6 ) : fatal error C1190:
      > managed targeted code requires a '/clr' option
      >
      > And that is regarding this:
      >
      > #using <mscorlib.dll >
      >
      > And then when I had /clr to the options, it then says:
      >
      > 1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line
      > options are incompatible
      >
      > So if I shut off /RTC1 in code generation, then it just says that
      > therer is another thing incompatible (/Gm I think) and it just keeps
      > going on with incompatibiliti es. Is there any way that I can make
      > this code work?
      >
      > ////////////////////////////////////////////////////////////////////////
      >
      > // Animal.cpp : Defines the entry point for the console application.
      > //
      >
      > #include "stdafx.h"
      >
      > #using <mscorlib.dll >
      >
      > using namespace System;
      >
      > __gc class Animal
      > {
      > public:
      > int legs;
      > void SetName(String *name)
      > { strName = strName->Copy(name); }
      > String* GetName() { return strName; }
      > private:
      > String *strName;
      > };
      >
      >
      > int _tmain()
      > {
      > Animal *cat, *dog;
      > cat = new Animal;
      > dog = new Animal;
      >
      > cat->SetName("Cat") ;
      > cat->legs = 4;
      > dog->SetName("Dog") ;
      > dog->legs = 4;
      >
      > Console::WriteL ine("Animal 1");
      > Console::Write( "Name: ");
      > Console::WriteL ine(cat->GetName());
      > Console::Write( "Legs: ");
      > Console::Write( cat->legs);
      >
      > return 0;
      > }
      >
      > //////////////////////////////////////////////////////
      >
      > I am using a regular Win32 console applications. Thanks alot.[/color]



      The example involves managed code, which is a non-standard Microsoft
      extension to C++ (and hence off-topic on this
      newsgroup). Incidentally, the version of managed code supported by VC++ 2003
      (and discussed in the book you have) is effectively obsolete, replaced by
      C++/CLI in VC++ 2005.

      The correct place to ask about this stuff is

      microsoft.publi c.dotnet.langua ges.vc


      --
      John Carson


      Comment

      • Alex Hardin

        #4
        Re: mscorlib.dll problem (Visual C++ 2005)

        Okay thanks, I did get the problem fixed on the other group. I didn't
        read anything about the book, I just saw it at the library and picked
        it up. I'll try and look for a 2005 book then. Or something. Thanks
        again guys.

        Comment

        • Michiel.Salters@tomtom.com

          #5
          Re: mscorlib.dll problem (Visual C++ 2005)


          Alex Hardin wrote:[color=blue]
          > Okay thanks, I did get the problem fixed on the other group. I didn't
          > read anything about the book, I just saw it at the library and picked
          > it up. I'll try and look for a 2005 book then.[/color]

          You probably don't want to look at all the 2005 extensions before
          learning
          the base language proper. Have a look at www.accu.org. It has a lot of
          book
          reviews, rated by experts. One of the better books is Accelerated C++,
          by
          A.Koenig. It's good for novices, either new to C++ or to programming in

          general. If you're one of the latter, don't be fooled by the thin
          appearance.
          It's complete, but has little fluff.

          HTH,
          Michiel Salters

          Comment

          Working...