mscorlib.dll problem (Visual C++ 2005)

Discussion in 'C++' started by Alex Hardin, Dec 17, 2005.

  1. Alex Hardin

    Alex Hardin Guest

    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\editing\my
    documents\alex\c++\animal\animal\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 incompatibilities. 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::WriteLine("Animal 1");
    Console::Write("Name: ");
    Console::WriteLine(cat->GetName());
    Console::Write("Legs: ");
    Console::Write(cat->legs);

    return 0;
    }

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

    I am using a regular Win32 console applications. Thanks alot.
    Alex Hardin, Dec 17, 2005
    #1
    1. Advertising

  2. Jacek Dziedzic, Dec 17, 2005
    #2
    1. Advertising

  3. Alex Hardin

    John Carson Guest

    "Alex Hardin" <> wrote in message
    news:
    > Hey,
    > I just downloaded Visual C++ 2005 Express, and I'm reading through a
    > book called "Visual C++ .NET Step By Step",


    Judging by the reviews on Amazon, it is a dreadful book.

    > 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\editing\my
    > documents\alex\c++\animal\animal\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 incompatibilities. 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::WriteLine("Animal 1");
    > Console::Write("Name: ");
    > Console::WriteLine(cat->GetName());
    > Console::Write("Legs: ");
    > Console::Write(cat->legs);
    >
    > return 0;
    > }
    >
    > //////////////////////////////////////////////////////
    >
    > I am using a regular Win32 console applications. Thanks alot.




    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.public.dotnet.languages.vc


    --
    John Carson
    John Carson, Dec 18, 2005
    #3
  4. Alex Hardin

    Alex Hardin Guest

    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.
    Alex Hardin, Dec 18, 2005
    #4
  5. Alex Hardin

    Guest

    Alex Hardin wrote:
    > 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.


    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
    , Dec 19, 2005
    #5
    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. Ankit Aneja
    Replies:
    5
    Views:
    11,599
    Steven Cheng[MSFT]
    Apr 6, 2006
  2. iceColdFire
    Replies:
    7
    Views:
    6,481
  3. roopsd
    Replies:
    0
    Views:
    1,696
    roopsd
    Aug 14, 2006
  4. Replies:
    1
    Views:
    2,043
    senfo
    Feb 27, 2007
  5. Replies:
    0
    Views:
    387
Loading...

Share This Page