在C ++中创建一个自包含的程序

编程入门 行业动态 更新时间:2024-10-27 15:27:35
本文介绍了在C ++中创建一个自包含的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在使用Visual Studio 2012.我希望创建一个完全独立的程序,可以在没有可视工作室的机器上使用,只需直接复制exe文件即可。我以前需要首先运行visual c ++ 2012可再发行以使程序工作。有什么办法使一切运行在一个exe?我不想使用安装程序,因为它是一个相当简单的程序;用户使用安装程序所需的时间可能会超过我的程序...

所以有什么办法静态链接一切吗?现在,它只是在新机器上运行时崩溃,但是一旦我在该机器上安装VS2012 express,它突然开始工作。

任何帮助将不胜感激。

解决方案

要在MFC项目中获得静态链接,请按以下方式设置项目属性

C / C ++代码生成,运行时库:多线程(/ MT)

配置属性,一般:使用MFC :使用MFC是一个静态库

一个简单的exe与这些属性将独立运行。

I'm using Visual Studio 2012. I wish to create a completely self-contained program that can be used on a machine without visual studio installed just by copying the exe file directly. I used to need to first run visual c++ 2012 redistributable to make the program work. Is there any way to make everything run in one exe? I would not like to use an installer either as it is a fairly simple program; the time it takes for the user to use the installer will probably be more than my program...

So is there any way to statically link everything? Right now, it just crashes when run on a new machine, but once I install VS2012 express on that machine, it suddenly starts to work.

Any help would be appreciated.

解决方案

To get static linking in an MFC project set the project properties (for the release build) as follows:

C/C++ Code Generation, Runtime Library: Multi-threaded (/MT)

Configuration Properties, General: Use of MFC: Use MFC is a Static Library

A simple exe with these properties will run standalone.

更多推荐

在C ++中创建一个自包含的程序

本文发布于:2023-11-14 03:15:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586063.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:创建一个   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!