C++ 在 Mac OS X 上为 XCode 安装 Eigen
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35658420/
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
Installing Eigen on Mac OS X for XCode
提问by Maria-Andersado
A while back it was a nightmare for me trying to get Eigen up and running on my mac for XCode, but a friend managed to figure it out and shared the instructions with me. I don't want anyone to go through what I went through, so here's an easy-to-follow guide.
不久前,我试图在 Mac 上为 XCode 启动并运行 Eigen 对我来说是一场噩梦,但一位朋友设法弄清楚并与我分享了说明。我不希望任何人经历我所经历的一切,所以这里有一个易于遵循的指南。
回答by Maria-Andersado
1. Install Homebrew
1. 安装 Homebrew
? Package manager for Mac, allows you to download pretty much anything with one Terminal command. Follow steps here.
? Mac 的包管理器,允许您使用一个终端命令下载几乎所有内容。按照此处的步骤操作。
2. Install Eigen
2. 安装本征
? Simply run the following command in Terminal: brew install eigen
? 只需在终端中运行以下命令:brew install eigen
? Eigen is now installed.
? Eigen 现已安装。
? Make note of the file path that is printed out on the command line! You'll need that later and it can vary from person to person.
? 记下命令行打印出来的文件路径!稍后您将需要它,它可能因人而异。
? Homebrew saves Eigen files in /usr/local/include/eigen3/
? Homebrew 将特征文件保存在/usr/local/include/eigen3/
3. Include Eigen files in your Xcode project's Build Path
3. 在你的 Xcode 项目的 Build Path 中包含 Eigen 文件
? Open the project you want to use Eigen with.
? 打开要使用 Eigen 的项目。
? Select your project's build target under TARGETS
? 在 TARGETS 下选择项目的构建目标
? Select the Build Settings tab.
? 选择构建设置选项卡。
? Scroll down to Apple LLVM 7.0 - Custom Compiler Flags Note that your version of the LLVM compiler may be different.
? 向下滚动到 Apple LLVM 7.0 - 自定义编译器标志请注意,您的 LLVM 编译器版本可能不同。
? Double click the blank space to the right of Other C++ Flags.
? 双击其他 C++ 标志右侧的空白区域。
? Add the directory where Eigen files are located in the filepath you noted back in step 2 (-I <filepath>
).
? 在您在步骤 2 ( -I <filepath>
) 中记下的文件路径中添加 Eigen 文件所在的目录。
? Search for HEADER_SEARCH_PATHS in your target build settings and add /usr/local/include/eigen3/
the same way you added the Eigen file path to OTHER_CPLUSPLUSFLAGS
.
? 在目标构建设置中搜索 HEADER_SEARCH_PATHS 并添加/usr/local/include/eigen3/
与将特征文件路径添加到OTHER_CPLUSPLUSFLAGS
.
Your project should be able to use Eigen with no issues now.
您的项目现在应该可以毫无问题地使用 Eigen。
回答by kmiklas
This worked for me, and seems a lot easier than the above. It's a little old-school, but no homebrew or package installer necessary. It literally took me less than 5 minutes.
这对我有用,似乎比上面的要容易得多。它有点老派,但不需要自制软件或软件包安装程序。从字面上看,我花了不到 5 分钟。
Download Eigen and unpack.
http://eigen.tuxfamily.org/index.php?title=Main_Page#DownloadCopy the "Eigen" folder into
/usr/local
directory. I sudo'd to root and did this in the terminal, because Macs are picky about what they let you see in finder. Like I said, old-school.
下载 Eigen 并解压。
http://eigen.tuxfamily.org/index.php?title=Main_Page#Download将“Eigen”文件夹复制到
/usr/local
目录中。我 sudo 需要 root 并在终端中执行此操作,因为 Mac 对它们让您在 finder 中看到的内容很挑剔。就像我说的,老派。
2a. Note: You might have to chmod
the permissions to 755.
2a. 注意:您可能需要chmod
755 的权限。
- In your project, go to "Build Settings" and search for "Header Search Paths." Add /usr/local/. Eigen is a header-only library!
- 在您的项目中,转到“Build Settings”并搜索“Header Search Paths”。添加 /usr/local/. Eigen 是一个只有头文件的库!
- Include Eigen like so
- 像这样包括特征