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?
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.
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.
Just choose Win32 Console Application. The drop down at the top of the window is irrelevant.
alt text http://img15.imageshack.us/img15/2029/screenmzi.jpg
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.
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 !
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?
Related
I'm trying to deploy a C++ app for use on multiple systems. I've already gotten everything to work in the release configuration. Now since i don't have any experience with deploys at all, i'd like to ask - what's the simplest way to deploy it from Visual Studio 2015 community, so that it could be installed as a portable app on flash drives and similar?
I've checked out google, but with no luck so far all of the solutions i checked require some sort of additional software that is only available for the pro version of VS.
The simplest possible answer would be: compile without dependency on VC++ runtime libraries (select this in the project properties -> C++ -> code generation) and choose the oldest Windows version it should run on (in project properties -> general). Maybe even select Windows XP compatibility.
This should be enough, unless your program depends on other libraries or optional Windows features that may be not present.
And test a lot :)
-- dd
You should be able to go to your project's Properties (right click on your project) then under C/C++ and Code Generation switch your Runtime Library from Multi-threaded DLL (/MD) to Multi-threaded (/MT).
This way your dependencies to the runtime library will be statically linked and not require you to have any of them installed at the target system.
I am trying to get an slightly older project running again. I used the code last summer just fine. Unfortunately I did not keep the VC++ project files, just the code. As such I created a new VC++ console project and selected the "empty project" option in the process. Upon adding the code and pointing the compiler and linker to the appropriate folder I compile successfully. From there I attempt to debug and receive the message
The program can't start because MFC71.DLL is missing from your
computer. Try reinstalling the program to fix this problem.
From what I see this DLL is in the Visual Studio .NET 2003 which as far as I can tell my project should have no dependency on. I am using a robotics simulation library called callisto which I suppose could depend on it. However that project seems to be gone so I can't confirm as much from the project website. How does one go about using MS development tools to determine as much? In the event that it does not, what other possible reasons would a new project depend on such an old DLL?
Note that if you are using that library in form of DLL (already compiled code that internally depends on redists of VS 2003), you can verify this by using the Dependency Walker (it is a simple .exe file that you can download here: http://www.dependencywalker.com/ and just drag-n-drop this DLL on it).
Also note that you don't need to install whole Visual Studio. Redistributable package for VS 2003 will do.
EDIT: "The Visual C++ 2003 runtime was not available as a seperate download" ~ check Where to download Microsoft Visual c++ 2003 redistributable
I've been working to a C++/CLI project in the last few months.
Now I'm back to C++ but seems that VS 2010 has set to use C++/CLI compiler even for standard C++ projects.
I just created a new C++ empty project but when I compile the code, it seems using C++/CLI compiler.
Intellisense is disabled as well.
How can I restore the default C++ compiler to my project ?
Choose Project -> Properties from the menu bar. In the Project properties window, under Configuration Properties -> General, make sure that Common Language Runtime Support is set to No Common Language Runtime Support.
I'm confused in my understanding of the relationship between Visual Studio and .NET. I want to write a C++ application, but not a ".NET C++" application. By this, I mean that my understanding is that everything built in .NET land gets compiled to a CLI-compatible intermediary code (just like "JVM" languages like Java and Groovy compile to the same bytecode).
But I don't want my app compiled to an intermediary bytecode...I want it compiled down to raw binary!
Does Visual Studio do this? Or is .NET forced down my throat the minute I choose VS as my C++ IDE? If so, whats a "raw C++" alternative to VS?
Thanks in advance!
Visual Studio is an IDE, which is orthogonal to any specific language or compiler.
Visual C++ is a compiler that supports the C, C++, and C++/CLI languages.
In Visual Studio, create a Visual C++ project from one of the 'Win32' (as opposed to 'CLR') project templates and your program won't have any .NET dependency.
there is that /clr compiler switch when compiling a c++ app. Without it, you will get a pure native binary and cannot use any. NET specific features within your code.
By selecting a project template or by setting the corresponding project property, VS will automatically choose if the switch is on or off.
Visual Studio still supports 100% native C++ applications as will as managed applications. When creating a new app just choose the "Win32 Console Application" to create a native application. For existing applications you can change / verify by doing the following
Right Click on the project and select "Properties"
Navigate to Configuration Properties -> C/C++
Make sure that "Common Language Runtime Support" is set to "No Common Language Runtime Support"
I have a C++ application only taking use of the basic Win32 API (I can remove that too if neccessary) and the C++ STL. I'm using MSVC and want it to be really standalone. I have already tried several options (including using the "Multithreaded" option instead of "Multithreaded DLL").
Yet: It misses several MSVC runtime DLLs on many computers including those in my school.
How can I create a C++ application able to run on Windows XP (and lower/higher if possible) without needing any specific DLL versions only avaiable with Service Packs and runtime-DLLs installed?
Do I have to switch to G++?
My requirements aren't that big.. Just a small executable, 35KB in size, containing some loops here and some ifs there.
Well, you already found the option you need to change. Right-click the project in the Solution Explorer window, Properties, C/C++, Code Generation, Runtime Library = /MTd. The resulting EXE only has a dependency on kernel32.dll, Windows.
Don't forget to also do this for the Release build configuration. Now choose /MT.
If you use static linking for all libraries you use, you should not need any DLLs. Are you sure you're not using MFC or ATL DLLs or something? Setting the runtime library to 'multithreaded' instead of 'multithreaded DLL' should do the trick for the CRT and remove any dependency on the MSVCRT DLLs. There should be a similar setting in general properties, like "use standard windows headers".
If you're using Visual Studio 2010, the CRT requires Windows XP SP2 or newer (so RTM or SP1 won't work). If you need to target prior to XP SP2, you probably need to go back down to Visual Studio 2008.