如何使用 Visual Studio Express 2005 制作完全静态链接的 .exe?
我目前首选的 C++ 环境是免费且非常出色的 Microsoft Visual Studio 2005 Express 版本.我不时将发布的 .exe 文件发送给其他人,结果令人满意.然而,最近我发现令人不安的结果是基于我想要的更多运气.尝试在旧的(2001 年份,未经过严格更新)XP 机器上运行其中一个程序时,只给我一条令人讨厌的系统无法运行 x.exe"(或类似)消息.
My current preferred C++ environment is the free and largely excellent Microsoft Visual Studio 2005 Express edition. From time to time I have sent release .exe files to other people with pleasing results. However recently I made the disturbing discovery that the pleasing results were based on more luck that I would like. Attempting to run one of these programs on an old (2001 vintage, not scrupulously updated) XP box gave me nothing but a nasty "System cannot run x.exe" (or similar) message.
一些谷歌搜索显示,使用此工具集,即使在简单的 hello-world.exe 中指定静态链接也会导致实际依赖额外的 .dll 文件(msvcm80.dll 等).一个令人难以置信的精心设计的版本计划系统(任何人的清单文件?)然后不会让 .exe 在没有完全正确的 .dll 版本的情况下运行.我不想要或不需要这些东西,我只想要一个老式的自包含 .exe,它只执行最低公分母 Win32 操作并在任何旧的 win32 操作系统上运行.
Some googling revealed that with this toolset, even specifying static linking results in a simple hello-world.exe actually relying on extra .dll files (msvcm80.dll etc.). An incredibly elaborate version scheming system (manifest files anyone?) then will not let the .exe run without exactly the right .dll versions. I don't want or need this stuff, I just want an old fashioned self contained .exe that does nothing but lowest common denominator Win32 operations and runs on any old win32 OS.
有谁知道是否可以用我现有的工具集做我想做的事?
Does anyone know if its possible to do what I want to do with my existing toolset ?
谢谢.
推荐答案
对于 C 运行时,请转到项目设置,选择 C/C++,然后选择代码生成".将运行时库"设置更改为多线程"而不是多线程 dll".
For the C-runtime go to the project settings, choose C/C++ then 'Code Generation'. Change the 'runtime library' setting to 'multithreaded' instead of 'multithreaded dll'.
如果您正在使用任何其他库,您可能需要告诉链接器显式忽略动态链接的 CRT.
If you are using any other libraries you may need to tell the linker to ignore the dynamically linked CRT explicitly.
相关文章