运行 .exe 不复制 .dll

Running .exe without copying .dlls

我有 Visual Studio 2015 解决方案准备交付。我要求 .exe 应该 运行 开箱即用。但是,我收到 "missing dll..." 错误。有什么办法可以让某人 运行 exe 无需下载一堆 ddls 吗?我可以构建 .exe 以某种方式独立执行吗?

是的,您必须静态 link 二进制文件。在项目设置中(Configuration Properties -> C/C++ -> Code Generation),分别使用 /MT、/MTd 用于 Release、Debug 配置。但是,这会使可执行文件的大小膨胀。

MSDN documentation on /MT, /MTd options