tags:

views:

235

answers:

4

I'm trying to compile a very simple C application using VS2008. My problem is that the resultant binary requires systems to have .NET installed. No actual code within the project uses .NET functionality, but I get errors during execution on any system that doesn't have .NET.

So, is there anyway to compile using VS2008 so the resultant binary can run on a system without .NET?

+3  A: 

In the Project Properties dialog, go to Configuration Properties | General. The option for "Common Language Runtime support" should be set to "No Common Language Runtime Support." Then Rebuild.

EDIT: Also check the Advanced Linker options whose names start with CLR. You shouldn't see any /CLR* settings for those 3 items. If you are using a non-default manifest, make sure it doesn't declare any CLR dependencies either.

sean e
Mine is set that way, but when I try to run the exe on a system without .NET I get this error: "The system cannot execute the specified program." When I install .NET it works fine.
Do you have any other indication that your binary requires .NET?
sean e
How are you installing .Net on the system? Are you installing .NET or Visual Studio? Are you trying to run a debug build on a system that does not have Visual Studio? The debug binaries are not redistributable.
sean e
It's C code (so obviously do .NET dependency), it's a release build of an exe, there is no installation (standalone exe).
The problem may be the C runtime, not .NET. In which case the simple solution is to use the statically linked versions. (In project properties -> C/C++ -> Code Generation, set Runtime library to MT Release (or MT Debug for debug builds).
jalf
+3  A: 

Simply create a C/C++ project. At the "New Project" dialog, under Visual C++, you have a bunch of options. All the ones in the CLR subcategory are .NET (C++/CLI), and the Win32 ones (as well as "Empty project") are native C/C++ projects.

You can change this setting on existing projects under project properties -> General -> Common Language Runtime Support.

Edit

It is possible that the problem isn't actually .NET, but the C runtime. In that case, specify the non-DLL versions under project properties -> C/C++ -> Code Generation -> Runtime Library.

(And if that is the case, you could have made things a lot easier for everyone by telling us what you knew, rather than what you'd assumed about the problem. ;))

jalf
A: 

Create a win32 Console Project.

anno
+1  A: 

As others have said, set the "Common Language Runtime support" option to "No Common Language Runtime Support." You said that didn't fix it, so .NET must not be the missing dependency. Have a look at the free Dependency Walker tool. This will show you all of the libraries your app depends on.

Don Pratt