我可以在 OS X 上使用 OpenFrameworks 而不必使用 XCode 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10586332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:19:26  来源:igfitidea点击:

Can I use OpenFrameworks on OS X without having to use XCode?

xcodemacosopenframeworks

提问by James Harcourt

I can't stand XCode, but really love OpenFrameworks, and I know it works on Linux+Win32 so I don't see why it shouldbe XCode dependent. If I need to have XCode installed that's fine, I just don't want to use it at all.

我受不了 XCode,但真的很喜欢 OpenFrameworks,而且我知道它可以在 Linux+Win32 上运行,所以我不明白为什么它应该依赖于 XCode。如果我需要安装 XCode,那很好,我只是根本不想使用它。

采纳答案by damian

Xcode internally uses gcc/llvm. in fact from the command line you can cd into a directory that contains an openFrameworks project and just type xcodebuild. but this won't allow you to edit the project file and add new source code, etc.

Xcode 内部使用 gcc/llvm。实际上,您可以从命令行 cd 进入包含 openFrameworks 项目的目录,然后键入xcodebuild. 但这将不允许您编辑项目文件并添加新的源代码等。

the Linux makefiles could be adapted to work on OSX as well. they already contain a lot of the information necessary about finding the correct source files, library paths etc. however Linux allows us to install many more components as shared system libraries, while on OSX we link most of the libs statically, so a number of extra library paths would need to be added. probably the biggest gotcha is that everything has to be compiled 32 bit, which means passing -arch i386everywhere, so you can't just install dependant libs using Homebrew or MacPorts. we are in the process of transitioning to 64 bit but there are still some QuickTime calls that require us to stick with 32 bit, mainly around accessing legacy video capture devices that a lot of us still use for computer vision.

Linux 生成文件也可以适用于 OSX。它们已经包含了很多关于找到正确的源文件、库路径等所需的信息。但是 Linux 允许我们安装更多的组件作为共享系统库,而在 OSX 上我们静态链接大多数库,所以一些额外的需要添加库路径。可能最大的问题是所有东西都必须编译为 32 位,这意味着-arch i386到处传递,所以你不能只使用 Homebrew 或 MacPorts 安装依赖库。我们正在过渡到 64 位,但仍然有一些 QuickTime 调用需要我们坚持使用 32 位,主要是围绕访问我们很多人仍然用于计算机视觉的传统视频捕获设备。

like @cdelacroix points out, we only maintain Xcode project files on OSX. this is mainly due to the lack of a decent alternative. there is a version of Code::Blocks for OSX but it is not very well supported, has some issues with native gui rendering and tends to lag behind the other platforms. Xcode is also the easiest way to install a toolchain on OSX so for most users installing Xcode is necessary.

就像@cdelacroix 指出的那样,我们只在 OSX 上维护 Xcode 项目文件。这主要是由于缺乏体面的替代品。有一个用于 OSX 的 Code::Blocks 版本,但它没有得到很好的支持,在原生 gui 渲染方面存在一些问题,并且往往落后于其他平台。Xcode 也是在 OSX 上安装工具链的最简单方法,因此对于大多数用户来说,安装 Xcode 是必要的。

if you do get a makefile based build system working, and would be interested in maintaining it medium to long term, please consider contributing it to the GitHub repository, it would be gladly accepted.

如果您确实让基于 makefile 的构建系统正常工作,并且有兴趣对其进行中长期维护,请考虑将其贡献给 GitHub 存储库,我们很乐意接受。

回答by Maxpm

As of March 2013, openFrameworks has official makefile support for compiling the library itself. However, at the time of this writing, the changes haven't yet been merged into the stable release. You'll need to clone the Git repositoryand switch to the development branch.

截至 2013 年 3 月,openFrameworks 已为编译库本身提供官方 makefile 支持。但是,在撰写本文时,这些更改尚未合并到稳定版本中。您需要克隆Git 存储库并切换到开发分支。

git clone https://github.com/openframeworks/openFrameworks
cd openFrameworks && git checkout develop
cd libs/openFrameworksCompiled/project
make

As far as I can tell, we still need to use the unofficial solutions for compiling apps against the library.

据我所知,我们仍然需要使用非官方的解决方案来针对库编译应用程序。

回答by tronda

Here's a link to a makefile which will compile an OpenFrameworks application on OsX:

这是一个 makefile 的链接,该文件将在 OsX 上编译 OpenFrameworks 应用程序:

https://gist.github.com/labe-me/1190981

https://gist.github.com/labe-me/1190981

Place the makefile in the apps' directory and run make. Tested on OsX 10.6, but haven't tried with addons yet.

将 makefile 放在应用程序的目录中并运行 make。在 OsX 10.6 上测试过,但还没有尝试使用插件。

回答by mipadi

You need Xcode, or at least a set of compilers (more information is available here), but otherwise, no, you can edit/work with the code in whatever editor or environment you want.

您需要 Xcode,或者至少需要一组编译器(此处提供更多信息),但除此之外,您可以在所需的任何编辑器或环境中编辑/使用代码。

回答by cdelacroix

As @mipadi said, there is no requirement to actually use Xcode, you can do pretty much everything you do in Xcode with make or cake or any of your build system of choice. All you have to do is find the right set of command line options to pass to the usual tools (compiler, linker, strip, etc.), and sometimes the easier way is to... look in the Xcode build window how it is doing stuff (expand the lines with the small button on the right of each line).

正如@mipadi 所说,不需要实际使用 Xcode,您几乎可以使用 make 或 cake 或任何您选择的构建系统在 Xcode 中完成您所做的任何事情。您所要做的就是找到一组正确的命令行选项以传递给常用工具(编译器、链接器、条带等),有时更简单的方法是……在 Xcode 构建窗口中查看它的情况做事(使用每行右侧的小按钮展开行)。

For example you can link with your framework of choice with ld -framework Framework -FPathToFramework foo.o or your dynamic library with ld -lLib -LPathToDylib foo.o. You might have to learn about @rpath, @loader_path and install_name_tool to ship a self-contained packaged application.

例如,您可以使用 ld -framework Framework -FPathToFramework foo.o 链接您选择的框架,或者使用 ld -lLib -LPathToDylib foo.o 链接您的动态库。您可能需要了解 @rpath、@loader_path 和 install_name_tool 才能发布自包含的打包应用程序。

As for OpenFrameworks, the "requirement" for Xcode is that the authors decided to maintain only Xcode project files. I just looked at how they do it, they ship source code and Xcode project files that build static libraries, so it will be even more simple for you (although you will need to link the library dependencies by hand). You will have to choose between compiling everything from source in your build system (if you want more customization power without touching Xcode), or just produce the 2 static libraries (openFrameworks.a and openFrameworksDebug.a) with Xcode once, then use them in your build system (recommended until you really need continuous customization).

至于 OpenFrameworks,对 Xcode 的“要求”是作者决定只维护 Xcode 项目文件。我只是看看他们是如何做到的,他们提供了构建静态库的源代码和 Xcode 项目文件,因此对您来说会更加简单(尽管您需要手动链接库依赖项)。您将不得不选择在构建系统中从源代码编译所有内容(如果您想要更多的自定义功能而不涉及 Xcode),或者只使用 Xcode 生成 2 个静态库(openFrameworks.a 和 openFrameworksDebug.a),然后在您的构建系统(推荐使用,直到您确实需要持续定制)。