学习在 Xcode 中编译 C++

2022-01-04 00:00:00 compilation c++ xcode

我已经开始在学校广泛使用 c++,现在我的程序已经到了有超过 1 个文件(即头文件、驱动程序、实现文件)的地步.我对软件开发的了解不够,无法通过查看苹果的指南来理解或掌握如何设置构建过程.有人可以教我如何在 xcode 中编译一个带有头文件和两个 C++ 文件的简单 C++ 项目吗?我首先需要制作一个makefile吗?

I have started using c++ extensively in school and now my programs are getting to the point where have more than 1 file (i.e. header, driver, implementation file). I don't know enough about software development to understand or get a grasp of how to setup the build process by looking at apple's guides. Could someone walk me through how to compile a simple c++ project with a header and two c++ files in xcode? Do I first need to make a makefile??

推荐答案

在 Xcode 中:

  • 选择文件 -> 新建项目...
    • 选择 Mac OS X -> 应用程序 -> 命令行工具(我假设您正在制作一个使用 stdin/stdout 的简单 C++ 应用程序,而不是基于 Cocoa 的 GUI)
    • 对于类型",选择C++ stdc++"
    • 点击选择..."并为项目指定名称和位置
    • 选择要添加到项目中的文件(标头和 .cpp 文件).

    如果您打算将 Xcode 用作主要 IDE,您将需要了解有关 Xcode 的更多信息.Xcode 有很多文档,但其中大部分是为创建 Cocoa 应用程序的人设计的.对于开发简单的 C++ 控制台应用程序,您可以从 Xcode 工作区指南.

    You will want to learn more about Xcode if you are going to use it as your main IDE. There's a lot of documentation for Xcode, but most of it is designed for people creating Cocoa apps. For developing simple C++ console apps, you can probably start with the Xcode Workspace Guide.

相关文章