"mscorlib.dll" Problem

A

Alex Hardin

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.
 
W

William DePalo [MVP VC++ ]

Alex Hardin said:
I just downloaded Visual C++ 2005 Express, ...
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
...
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?

You have two choices, easy and hard.

The hard way is to come up to speed on the meaning of the compiler options,
understand the incompatibilities and then set the switches appropriately for
your project.

The easy way is to have the wizard generate a project for you and then add
your source (files) to that project.

I don't have the Express Edition loaded here, but when I choose
File->New->Project from the Professional menu, under the C++ project types
there is a CLR choice. If I select that, in the right pane there is a "CLR
Console Application" template. If you are doing ordinary character mode
screen I/O (i.e. no windows) then this is the template you want. Type a name
for your project and click OK

The IDE will create a main() function for you which you can edit..

Just by the way, this is the command line that the IDE uses to build the
project:

/Od /D "WIN32" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /FD /EHa /MDd
/Yu"stdafx.h" /Fp"Debug\test.pch" /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3
/nologo /c /Zi /clr /TP /errorReport:prompt /FU
"c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll" /FU
"c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" /FU
"c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.XML.dll"

Regards,
Will
 
A

Alex Hardin

Hey, thanks alot! That and a combination of other things worked.
Learning what on earth CLR and managed C++ is really helped ;) Thanks
again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top