将 GLM 添加到 Xcode 4 中的项目

发布于 2025-01-04 08:24:36 字数 319 浏览 0 评论 0 原文

我正在尝试将 GLM 添加到 Xcode 4 中的项目中,但无法编译它。我已通过添加文件对话框将 glm 文件添加到我的项目中。

我遇到词法/预处理器问题,并且 Xcode 找不到文件

我不确定我需要调整什么才能构建它。

我已经看到 如何添加 OpenGL 数学 (GLM)已经到 Xcode 4 了吗?

I am trying to add GLM to a project in Xcode 4, but I cannot get it to compile. I have added the glm files to my project through the add files dialog.

I get a lexical/preprocessor issue and Xcode cannot find the file <cmath>.

I am not sure what I need to tweak to get this to build.

I have seen How do I add OpenGL Mathematics (GLM) to Xcode 4? already.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

走过海棠暮 2025-01-11 08:24:36

您需要做的就是将文件添加到项目中并#import "glm.hpp"(对于 Objective-C++;对于简单的 C++,它应该只是 #include "glm.hpp" )。

有几件事需要注意:

  • 当您下载 OpenGL 数学库时,它附带了一堆您不需要的东西(测试代码、无关的实用程序)。将这些添加到您的项目中将导致我无法消除的编译错误。您唯一需要的目录是 glm/ 目录;您可以删除 test/util/doc/bench/ 目录。如果您尝试遵循“如何添加 OpenGL”数学 (GLM) 到 Xcode 4?” 并且仍然遇到问题,这可能是困扰您的问题。

  • OpenGL 数学文档告诉您要包​​含 或 文件。在 Xcode 4 中,您应该包含它们,例如“glm.hpp”或“*.hpp”。无论文件位于项目中的哪个位置,Xcode 都会找到它们。据说您可以添加用户定义的构建设置“USE_HEADERMAP”并将其设置为“NO”以禁用此功能,但我对此没有任何运气。

  • 并且,为了以防万一,请注意,使用 OpenGL 数学库的代码文件必须是 Objective C++ 文件(以“.mm”结尾),而不是默认/纯 Objective C 文件(以“.mm”结尾)在“.m”中)。毕竟它很大程度上是一个 C++ 库...:-)

我希望有所帮助。我自己只是在解决这个问题,而且还没有机会真正推动这个(例如,我基本上只是添加了一两个 mat4 对象并确保东西仍然编译),但它似乎正在发挥作用。

All you need to do is add the files to the project and #import "glm.hpp" (for Objective-C++; for simple C++ it should just be #include "glm.hpp").

A couple things to be careful of:

  • The OpenGL Mathematics library, when you download it, comes with a bunch of stuff you don't need (test code, extraneous utilities). Adding these to your project will result in compile errors which I could not get rid of. The only directory you need is the glm/ directory; you can delete the test/, util/, doc/, and bench/ directories. If you were trying to follow "How do I add OpenGL Mathematics (GLM) to Xcode 4?" and were still having problems, this may be the thing which was tripping you up.

  • The OpenGL Mathematics documentation tells you to include the or files. In Xcode 4, you should include them like "glm.hpp" or "*.hpp". Xcode will find the files no matter where in the project they are. Supposedly you can add a user-defined build setting "USE_HEADERMAP" and set it to "NO" to disable this, but I didn't have any luck with that.

  • And, just in case, note that your code files using the OpenGL Mathematics library must be Objective C++ files (ending in ".mm"), not the default/plain Objective C files (ending in ".m"). It is very much a C++ library after all... :-)

I hope that help. I was just working through this myself, and I haven't had the chance to really push this (e.g. I've basically just added a mat4 object or two and made sure things still compiled), but it seems to be working.

把回忆走一遍 2025-01-11 08:24:36

我遇到了同样的问题,我将 ViewController.m 重新管理为 ViewController.mm 解决了它。将扩展名更改为 .mm 告诉 XCode 该文件内部可能包含 C++ 代码。文章 编写 Object-C 代码类和对象部分对此进行了解释。

I ran into the same problem and I solved it remaning my ViewController.m to ViewController.mm. Change the extension to .mm tells XCode that the file may contain C++ code inside. The article Write Object-C Code explains this in the Classes and Objects section.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文