1

I am compiling with GCC 4.8.2 (MinGW) on Windows. I am using openMP in my program. When I compile without -static flag I get this output from dumpbin /dependents myapp.exe:

Dump of file myapp.exe

File Type: EXECUTABLE IMAGE
  Image has the following dependencies:

    KERNEL32.dll
    msvcrt.dll
    USER32.dll
    libgomp-1.dll

Now including libgomp-1.dll in the same folder as myapp.exe won't be enough as that depends on some more .dlls (libwinpthread-1.dll and libgcc_s_seh-1.dll) and dumpbin only goes one level deep.

Now I compile including -static in compilation flags and I get this output from dumpbin:

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    KERNEL32.dll
    msvcrt.dll
    USER32.dll

Is it now going to work without .dlls on which libgomp-1.dll depends? Did GCC include static version of those libraries as well? Would dumpbin be able to detect those new dependencies ?
(I am probably getting a bit paranoid here but those things are very difficult to test on local machine where I have those dlls in many places on my PATH)

Piotr Lopusiewicz
  • 2,514
  • 2
  • 27
  • 38
  • The `kernel32` and `user32` libraries are part of the operating system. They can't be linked statically (because that would mean duplicating part of the operating system in your executable, which doesn't make sense) but by the same token they don't need to be. – Harry Johnston Feb 16 '15 at 04:44

1 Answers1

2

You can't link MSVCRT (the Windows C Library) static with MinGW, but that shouldn't be much of a problem. MSVCRT.dll, KERNEL32.dll, USER32.dll should be present on all Windows versions. You don't need to redistribute them.

Thomas
  • 3,074
  • 1
  • 25
  • 39
  • Relevant: http://stackoverflow.com/questions/1073509/should-i-redistribute-msvcrt-dll-with-my-application – Harry Johnston Feb 16 '15 at 04:56
  • The question is not about linking with MSVCRT but about the question if dumpbin is going to detect dependencies of now statically included libgomg-1.dll (it didn't before using -static as it only analyzes one level). Sorry to be unclear about it. – Piotr Lopusiewicz Feb 16 '15 at 07:20
  • @Piotr Lopusiewicz: Yes of course, it will just show up as a dependency of `myapp.exe` then. – Thomas Feb 16 '15 at 10:12