VisualStudio C++ created executable not deployable on other Win10 computers (error "0xc000007b")

0

When I compile a simple "Hello World" C++ program with VisualStudio (2017 community edition), the executable runs on the devolopment computer with Windows 10, but on a different computer with the same OS and architecture, the program fails to start with an error "0xc000007b" ("Application was unable to start correctly").

Does someone have suggestions what I could try out to create a portable executable with VisualStudio? It seems to be a common problem with VisualStudio, but I have not found anything useful on the web for solving it.

Here is the C++ code of my program:

#include <Windows.h>

int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int cmdShow)
{
    MessageBox(NULL, "Program started", "Message", MB_OK);
    return 0;
}

This is the used set of compile options according to VisualStudio (Release mode for x64):

/GS /TP /W3 /Zc:wchar_t /I"D:\test\build" /I"D:\test"
/I"C:\Program Files (x86)\Visual Leak Detector\include" /Gm- /O2 /Ob2
/Fd"test1.dir\Release\vc141.pdb" /Zc:inline /fp:fast /D "_WINDOWS"
/D "_VARIADIC_MAX=10" /D "NOMINMAX" /D "NDEBUG" /D "CMAKE_INTDIR=\"Release\""
/D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /Oy /MD /Fa"Release/"
/EHsc /nologo /Fo"test1.dir\Release\" /Ot /Fp"test1.dir\Release\test1.pch" /diagnostics:classic

And this is the list of libraries linked into the executable as reported by dumpbin:

D:\test\build\Release>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\dumpbin.exe" /DEPENDENTS test1.exe
Microsoft (R) COFF/PE Dumper Version 14.16.27032.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file test1.exe

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    USER32.dll
    VCRUNTIME140.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    KERNEL32.dll

  Summary

        1000 .data
        1000 .pdata
        1000 .rdata
        1000 .reloc
        1000 .rsrc
        1000 .text
windows
visual-c++
asked on Stack Overflow Jan 27, 2020 by cdalitz

1 Answer

1

You need to install the appropriate Visual C++ Redistributable on the target computer.

Redistributable for Visual C++ 2015, 2017, 2019

On your development computer this is already installed with Visual Studio.

answered on Stack Overflow Jan 27, 2020 by Simon

User contributions licensed under CC BY-SA 3.0