Sam
Sam

Reputation: 4497

Importing Armadillo C++ library into Xcode

I'm a mac user and am trying to install and import C++ Armadillo library. Here are the steps I've had so far:

1) I downloaded the Armadillo library from its website.

2) I went over the Readme.txt file in the download file explaining how to install it.

3) I used CMake to make the armadillo download files into binary files.

4) Then by using terminal and the code sudo make install, I installed the binary codes and they generated some "library-like" files: libarmadillo.4.0.2.dylib, libarmadillo.4.dylib, lib armadillo.dylib

5) I then copied all these files into /url/lib directory.

6) Now I have my Xcode program running and I'm trying to include the armadillo library via the include command. The problem is Xcode highlights this line and it says "armadillo file not found". Could anyone please help me solve this issue?

Thanks very much,

Upvotes: 5

Views: 5156

Answers (1)

Martin J.
Martin J.

Reputation: 5118

You need to set the following things in your build settings:

  • Header Search Paths: /path/to/armadillo/include (e.g. something like /url/lib/armadillo/include)

This is all you need for your source to compile. However, in order to get your program to link, you will also need the following:

  • Library Search Paths: /path/to/armadillo/libraries (e.g. something like /url/lib/armadillo/lib)
  • Other Linker Flags: -larmadillo (or: add the armadillo library to your Link build phase using the GUI)

If you're not exactly sure how to properly build and install armadillo (e.g. which prefix to use when configuring), I highly recommend using a package manager such as MacPorts to do it for you,

  1. Install port from here
  2. run the following command:

    sudo port install armadillo

  3. Your header path and library path will be: /opt/local/include and /opt/local/lib respectively

Upvotes: 5

Related Questions