views:

414

answers:

6

I am writing a plain vanilla c++ console app using VS 2008. When I create the project, the IDE gives me a choice of .net versions. There is no option for 'none'. When I look at the project properties page, the Targeted Framework has whatever value I chose and is greyed out.

When I try and run the app on a windows machine without the clr, it gives me a setup error and quits.

There is nothing in my code that has anything to do with .net. How can I escape the clutches of .net and the clr?

+5  A: 

How are you creating the project? If I start Visual Studio 2008 and go File / New / Project... / Other languages / Visual C++ / Win32 / Win32 Console Application, I get a plain old C++ project with no .net dependency.

RichieHindle
A: 

Also if you right click the project in the solution explorer and go to Properties->Configuration Properties->General

You should be satisfied to see that the "Common language support" field should be set to "No common language support" if you followed the above advice i.e. compiling with no clr !

Roman M
+1  A: 
consultutah
+2  A: 

Make sure that you chose the "Win32 Console Application" project type. This will give you a C++ only project. Most of the other console options will bind the project to .Net.

JaredPar
That did it. Thanks
Jon
A: 

The problem (based on your comment under the question) has nothing to do with .NET.

The problem is most likely how you link to the C runtime library. Visual Studio defaults to using the dynamically linked (dll) version, which means that dll has to be present on the target machine.

The simple fix is to change your project to use the statically linked version. Under project properties -> C/C++ -> Code Generation, set Runtime Library to Multi-Threaded or Multi-Threaded Debug (but not Multi-Threaded (debug) DLL).

Alternatively, you have to deploy the runtime dll along with your program.

jalf
A: 

Use Dependency Walker to find out which DLLs are needed to yours program. May be problem is not with .NET, and with Runtime or ATL libraries. Did you used static linkage?

Kirill V. Lyadvinsky