gpt4 book ai didi

c++ - 将 C++ (.cpp) 编译成 .exe 文件

转载 作者:行者123 更新时间:2023-11-28 02:00:55 27 4
gpt4 key购买 nike

:) 非常感谢帮助。

我希望将 .cpp 文件转换为 .exe。

我试过 (MingW) gcc 和 g++。我还尝试在 Visual Studio 中手动编译它。

不幸的是,这些无法编译(在 Linux 和 Windows 上),因为无法找到预编译的 header :

stdafx.h: No such file or directory

我尝试手动下载它们(预编译头文件:#include)并更改 #include <stdafx.h>#include "stdafx.h"指向手动下载的预报头的当前文件夹。这“有效”但它编译时出现大量错误,可能是因为它是 header 的错误版本(我唯一能找到 header 的地方是 https://sourceforge.net )

一定有更简单的方法吗?

最佳答案

您可能使用了需要 stdafx.h 的项目模板。

要解决它,您可以删除 cpp 文件中的 #include "stdafx.h"

或者,在使用 VS 模板创建新项目时关闭 Precompiled header 选项。例如,Win32 控制台应用程序 模板:

enter image description here

enter image description here

关于c++ - 将 C++ (.cpp) 编译成 .exe 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39597119/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com