views:

99

answers:

4

i was wondering how programs like ccleaner and utorrent are made? AFAIK they are written in C++ but they run without the need of .net framework and apparently run on windows 98 as well. How can this be done? Visual c++ requires .net framework to be installed to run the binary file.

While .net framework is free, it can be a hassle and it would probably turn many users away as the setup is 20MB+ and installs several files/registry entries.

+2  A: 

Create native C++ project, without using CLI. In VC++ Application Wizard you can select any type, except of CLI.

Native C++ project has its own runtime requirements: C/C++ runtime, MFC runtime (if MFC is used), but .NET Framework is not required.

Alex Farber
Thanks for the reply.
luq
+8  A: 

Visual c++ requires .net framework to be installed to run the binary file.

No, it does not. In fact, C++ and the .NET framework are highly unrelated. You only need the .NET framework if your application is written in C++/CLI, which is far away from regular C++.

If you develop an application in standard C++, you don't need the .NET framework, just the runtime shipped with your toolchain (Visual C++, mingw, whatever). In some cases you can also link to the runtime statically, so you don't even need to distribute DLLs etc.

As for creating GUIs in regular C++, there are toolkits out there. Microsoft offers the bare Windows API, MFC, WTL and there are 3rd party products, like Qt or wxWidgets

Jim Brissom
Thanks for the reply, the toolkits tip should come in handy.
luq
+2  A: 

When creating the project, set it up as a Win32 project, not a CLR project. That will ensure that you're compiling against the C++ standard rather than the managed C++ variant used for .Net.

andand
Thanks for the feedback. I did try creating a win32 project but it is a lot less straight forward than creating a forms application (which requires .net framework). Forms applications are what I'm familiar with so maybe i'll give it another shot.
luq
@luq: You've just discovered one of the reasons that .Net is popular. You might want to check out Qt (http://qt.nokia.com ... the LGPL version is free) which offers a library of cross-platform UI tools for standard C++ (i.e. not .Net). It can be used with Visual Studio 2010 or you can use Qt Creator which is a full IDE for C++ development using Qt.
andand
+1  A: 

It's important to understand the difference between native and managed code on Windows. There is basic discussion of that topic on SO here and a deeper dive from a Microsoft person here.

Your concern about taking a dependency on .Net Framework may be out of date - new PCS would have it installed by default since Vista and Windows 7 include it, and many older ones will have it due to existing .Net apps or via Automatic Update from Microsoft - there is some info on .Net version relative penetration rates here.

That said, I would not choose C++/CLI unless you have native/managed code interop requirements - use C++ for native and C# for managed code.

Steve Townsend
Thanks for the feedback. My main concern is that a good percentage of end users would not have .net framework installed and having to install a 20+MB file to run a considerably smaller application isn't exactly convenient. I'll take a look at the links provided as well since I haven't exactly wrapped my head around the concepts of native and managed code.
luq