Installing Eigen on Mac OS X for XCode

30,781

Solution 1

1. Install Homebrew

• Package manager for Mac, allows you to download pretty much anything with one Terminal command. Follow steps here.

2. Install Eigen

• Simply run the following command in Terminal: brew install eigen

• Eigen is now installed.

• 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/

3. Include Eigen files in your Xcode project’s Build Path

• Open the project you want to use Eigen with.

• Select your project’s build target under 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.

• Double click the blank space to the right of Other C++ Flags.

• Add the directory where Eigen files are located in the filepath you noted back in step 2 (-I <filepath>).

• 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.

Your project should be able to use Eigen with no issues now.

Solution 2

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.

  1. Download Eigen and unpack.
    http://eigen.tuxfamily.org/index.php?title=Main_Page#Download

  2. Copy 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.

2a. Note: You might have to chmod the permissions to 755.

enter image description here

  1. In your project, go to "Build Settings" and search for "Header Search Paths." Add /usr/local/. Eigen is a header-only library!

enter image description here

  1. Include Eigen like so

enter image description here

Share:
30,781

Related videos on Youtube

Maria-Andersado
Author by

Maria-Andersado

Updated on June 28, 2020

Comments

  • Maria-Andersado
    Maria-Andersado almost 4 years

    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.

  • Dirk
    Dirk about 8 years
    I tried this with a blank Xcode C++ command line tool project template. Upon compilation I get "cannot specify -o when generating multiple output files" error. How do I add the compiler option? Just entering the path of my Eigen installation?
  • Christina Daniel
    Christina Daniel almost 4 years
    I have the same problem...^^
  • smriti
    smriti about 3 years
    Thank you very much!
  • Sahas
    Sahas over 2 years
    Thanks! this is the best answer which also answers a lot of other questions!!