Suppose that we have a simple c code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
printf("hello\n");
}
If we compile this source with icc, will the final executable need any additional library to run on a windows7 machine for example? What will happen if I compile it with visual studio? Will I need to install a different redistributable library for each compiler I use? Is there any way to avoid this? Will it work if I copy the required library files to the same directory with the executable?
Link the static version of the CRT. In msvc that's done with Project + Properties, C/C++, Code Generation, Runtime Library = /MT or /MTd. Don't know icc, it should have something similar.
The default is /MD to use the DLL version of the CRT. But you must make sure that DLL is installed on the target machine. /MD is the safe choice, you won't likely have memory management problems when you use DLLs with exported functions that expose C++ classes like std::string.