Question

I'm using armadillo for a project, and in general it's been working well. The project is Xcode based, and so far the only way I've managed to get it working is with (adding a header search path of /usr/include/ doesn't seem to work):

#include "/usr/include/armadillo"

Well now I'm trying to do some matrix multiplications for the first time, and I've done the simplest thing I could think of to make sure there's no other cause.

mat aa = eye(3,3)*eye(3,3);

but this gives me the linker error:

*"_wrapper_dgemm_", referenced from:

void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)in DynamicGridPoint.o

Anyone know what could be causing this? The examples (which include matrix multiplication) compile just fine from the command line, so I assume this is to do with my xcode setup

EDIT BASED ON ANSWERS SO FAR

so I've tried to link to the run time library by including -larmadillo in the project's 'Other Linker Flags', and adding '/usr/lib' to the Header and Library search paths, but I get the link error: 'ld: library not found for -larmadillo'

any thoughts on why this could be happening?

/usr/lib contains the following (relevant) files:

  • libarmadillo.3.80.2.dylib
  • libarmadillo.3.dylib
  • libarmadillo.dylib
Was it helpful?

Solution

You're not linking against the armadillo run-time library (eg. -larmadillo).

To fix this, either configure Xcode to link with the armadillo run-time library, or edit Armadillo's configuration so that it doesn't use its run-time library.

The latter is done via editing "include/armadillo_bits/config.hpp" and commenting out ARMA_USE_WRAPPER. You will then need to link against lapack and blas directly (eg. -llapack -lblas), or use the Accelerate framework (eg. -framework Accelerate).

OTHER TIPS

You need to link the armadillo shared library. In the Makefile in the examples, the rules to make are:

all: example1 example2                                                          

example1: example1.cpp  
  $(CXX) $(CXXFLAGS)  -o $@  $<  $(LIB_FLAGS) 

LIB_FLAGS is defined earlier as

LIB_FLAGS = -larmadillo $(EXTRA_LIB_FLAGS)

ifeq (macos,macos)                                                              
  EXTRA_LIB_FLAGS = -framework Accelerate                                     
endif

So in your XCode project you need to find a way to include libarmadillo. The Accelerate framework is optional; I've never used it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top