delete_this_account
delete_this_account

Reputation: 2446

Different compilers... Will I need to install redistributable libraries for all?

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?

Upvotes: 0

Views: 124

Answers (2)

Hans Passant
Hans Passant

Reputation: 941625

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.

Upvotes: 1

user2100815
user2100815

Reputation:

Compile it with TDM MinGW - there will be no dependencies except on MSVCRT.DLL which comes with all recent versions of Windows.

Upvotes: 1

Related Questions