we have a legacy software with using c++ dlls and now we r trying to build it again in visual studio but it is not running on pcs where visual studio is not installed.
What is reason for this??
This is a problem I have run into several times, with 2 main causes.
If the 'other' PCs do not have the redistribution package for that version of the compiler, your code might not run. There is a separate package for each version of Visual Studio (ie. VS6, VS.Net2002, VS.Net2003, VS2005, VS2008, VS2010, VS2012...).
If you build your targets with "Debug" settings and ship the targets to other machines, those 'other' machines will not be able to run your code unless they either have the same Visual Studio compiler installed or you have manually installed the debug DLLs for that compiler. Note that the redistribution package is only available in Release form. The debug DLLs are not licensed for redistribution.
You can write portable C++ code, but you cannot make an executable module multi-platform for native-code C++ project. Executable files have different formats for different platforms; there are many of them, and even if the CPU instruction-set architecture is the same, OS calls are linked into it. And if the CPU instruction-set architecture is different, you code may very likely crash/hang if the target is different from the CPU you try to use during run-time.—SA
Of course, Visual Studio is not required to use the compiled code, but some C++ solutions will need "Visual Studio redistributable package". The installations are available free of charge from Microsoft for each version of Visual Studio. Please find the one you need in MSDN.
You really need to learn how code is built, loaded and executed; the whole lifetime cycle.
It does not hold for C++/CLI. If you write pure CLI code and do it very accurately, in a perfectly portable manner, you can get code running on many different OS without recompilation. It includes different versions of Window, Linux, Mac OS X, iOS and more. On non-Microsoft platforms, it requires Mono, on Microsoft it could be either .NET or Mono.
Sorry, I'm not providing any references, as I don't know if you are interested in CLI or not. You can very easily find them in Wikipedia and Microsoft documentation, or ask some follow-up questions.
Edited 20-Jan-13 18:31pm
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)