views:

72

answers:

2

I have Visual c++ 2010 express installed. I develop some apps with it (mainly console based for now).

I usually compile via the cl.exe command line option. Does these apps that I compiled with Visual C++ require .net framework to run?

Also what exactly is the object code file?

Lastly, I know that mono has Windows Form 2.0 fully implemented. Which version of the .NET framework corresponds to WinForm 2.0? (I'm guessing .NET 2.0?) Does this mean that I have to use Visual Studio 2005 to develop or can i create a new project with different .net version with Visual studio 2010?

Thanks

A: 

In order:

  1. No, your apps will not require the .NET Framework as long as you stuck with pure C++ (i.e., avoided C++/CLI). If you linked to the C runtime library dynamically (/MD), however, your apps will require the "Microsoft Visual C++ 2010 Redistributable" to be installed.

  2. Object code is an intermediate representation. Your source files have been compiled into x86 (or amd64) instructions, but still need to be linked together with runtime libraries before they can be used. Except in unusual circumstances, the .obj files are not considered part of the final app and do not need to be packaged.

  3. Currently .NET Framework 2.0, 3.0, 3.5, and 4.0 correspond to WinForms 2.0. Since they largely share the same CLR, you do not have to use VS2005 to develop compatible applications as long as you stay away from newer functionality. Conveniently enough, Microsoft has halted development of WinForms, so just avoid WPF stuff and you'll be set.

ChrisV
Thanks for the response. What about object code? Is it safe to delete it? And I'm not looking for an app to be installed, rather it will be ran portably.Also about this VC 2010 redistributable, is there anyway to not use this?
ultimatebuster
Yes, it's safe to delete *.obj after a build.To avoid the VC++2010 redistributable requirement, compile with /MT or /MTd.
ChrisV
A: 

Whether or not your application needs the .NET framework depends on how you compile. If you pass the /clr flag to the compiler, it will generate C++/CLI code, which does require (and allow you to use) the .NET framework.

Otherwise, you get a native C++ app, which doesn't require it.

If you want to use Winforms, which are part of .NET, you have to use the /clr flag. As ChrisV mentioned, if you compile with /MD or /MDd, your program requires the VC++ runtime library. If you compile with /MT or /MTd, the runtime is statically linked into your app, so no separate .dll is required.

jalf
I'm compiling using the option /EHsc
ultimatebuster