Reputation: 6335
I had the following question about programming in VC++ 2008
I am learning VC++ and just wanted to get the about doubts cleared. Hope they will be cleared soon!
Thanks in advance and Cheers
Upvotes: 1
Views: 255
Reputation: 104474
For the most part... but bear in mind this:
If you want to program without the .NET framework, choose any of the "Visual C++" projects when creating a new project - but don't use any of the CLR projects.
Native C++ apps (console or windowed) will run on older Windows operating systems so long as you don't link in function calls or APIs that are only available in newer operating systems. For example, don't call StgMakeUniqueName and expect your app to work on Windows XP. But it is rather easy to get a console C/C++ application compiling on the latest version of Visual C++ running on Win7 to produce EXEs that run on XP.
I believe you can prevent accidental usage of using new APIs by making use of the _WINNT_WIN32 define.
The other consideration with native C++ applications on Windows is that by default, Visual C++ will choose dynamic linking for including the C-RunTime (e.g. msvcrt100.dll). These DLLs aren't always available on the machines you copy your EXE to. When you run your EXE on a different computer, you might get an application error about not being able to find MSVCRT*.dll. If this happens, you can either switch to static linking in the project settings (and then just copy the EXE directly to the other machines), or pre-install the appropriate MSVCRT on the other computers you want to run your EXE on. Visual Studio pre-installs the MSVCRT as part of its own setup. And Visual Studio ships with MSI files for installing MSVCRT that you can redistribute. Debug builds of your EXE may require some manual copying of the debug build of MSVCRT DLLs to target machines. Choose static linking for debug builds or just have debug builds of your app link with retail MSVCRT.
The same consideration holds true for MFC and it's associated DLLs if you choose to use that framework for UI Development. (But you said console apps, so you don't have to worry about this).
Your EXE won't run on Linux without some hacking. (Recompiling is easier). But if you program your console application in .NET, the EXE has a high chance of running on Linux with Mono.
Upvotes: 3
Reputation: 13690
Regarding your question 2: When you build a C++ application you will still have to make sure that your target system has all the run-time libraries for the applicaiton. The Visual Studios (and even the VS services packs) come with different version of that run-time libaries. These are installed in the side-by-side cache WinSxS.
When you deploy your application you should add a VCRedist.exe for the run-time libraries you used when building you application.
Upvotes: 1
Reputation: 987
Good luck.
Upvotes: 2
Reputation: 9466
3: If you write portable C++ console application (not using Windows specific functions), you can simply recompile for other platform using some compiler targeting that platform.
Upvotes: 0
Reputation: 2807
1> Depends: if don't use any Windows 7 specific API, you will have no problems running the program on Windows Vista; if you don't use any Vista specifica API you will have no problem running it on XP, etc.
2> Sure, you just need to make a native only project instead of a C++/CLI one
3> You will need an emulator like "wine" to run windows executables under linux
Upvotes: 3