4

I have installed dlib using Homebrew.

brew install dlib

How can I create a C++ project that uses dlib in Xcode ? I have tried some build settings. However, it does not work.

  • Add /usr/local/Cellar/dlib/19.1_2/include to Header Search Paths
  • Add /usr/local/Cellar/dlib/19.1_2/lib to Library Search Paths
  • Add -ldlib to Other Linker Flags

I have got these errors:

Undefined symbols for architecture x86_64:
"_cblas_dgemm", referenced from:
  dlib::blas_bindings::cblas_gemm(dlib::blas_bindings::CBLAS_ORDER, dlib::blas_bindings::CBLAS_TRANSPOSE, dlib::blas_bindings::CBLAS_TRANSPOSE, int, int, int, double, double const*, int, double const*, int, double, double*, int) in main.o
"_cblas_saxpy", referenced from:
  dlib::blas_bindings::cblas_axpy(int, float, float const*, int, float*, int) in main.o
"_cblas_sscal", referenced from:
  dlib::blas_bindings::cblas_scal(int, float, float*) in main.o
"_dgesvd_", referenced from:
  dlib::lapack::binding::gesvd(char, char, int, int, double*, int, double*, double*, int, double*, int, double*, int) in main.o
ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

fivetech
  • 361
  • 2
  • 13
  • did you tried compiling it from sourcecode? – Evgeniy Oct 03 '16 at 06:50
  • @Evgeniy Yes, I tried. I got the same result. I have found that dlib is trying to access BLAS while compiling my program. It is provided in Accelerate.framework on macOS. After adding that framework to project, the problem has been solved. – fivetech Oct 03 '16 at 15:27
  • I am having the same issue. I am trying to compile through the command line with cmake, though. You wouldn't know how to add this to the cmake files, would you? – K. Shores Oct 27 '16 at 22:14
  • First, you need to find out where Accelerate.framework is. Then, you can add it to the cmake files. However, I don't know how to add it. I am not quite familiar with cmake. Alternatively, you may use OpenBLAS library. However, I have never tried it. – fivetech Oct 29 '16 at 12:10
  • @fivetech so, have you solved that issue? If yes, could you write little guide, please? – Dmytro Rostopira Jan 19 '17 at 14:35
  • I have added answer. – fivetech Jan 19 '17 at 19:21

2 Answers2

4

By default, homebrew installs dlib without any BLAS library. I have solved the issue by linking Accelerate.framework with binary file.

Accelarate.framework is provided by Apple. It includes everything that dlib needs. Further information: https://developer.apple.com/reference/accelerate

In order to add that library to your project,

  1. Choose the project name in project navigator (Left Side).
  2. If it is not appeared on the editor, click "Show project and targets list" and choose target binary.

    enter image description here

  3. Choose "Build Phases" shown below. enter image description here
  4. Expand "Link Binary With Libraries" and click add items icon.
  5. Search Accelerate.framework and add it.
  6. Change its status to "Required".

Alternatively, it may work if you uninstall dlib and install dlib with brew install dlib --with-openblas command. However, I haven't tested it yet.

By the way, Homebrew warns about openblas if you brew info openblas:

macOS already provides this software and installing another version in parallel can cause all kinds of trouble.

fivetech
  • 361
  • 2
  • 13
0
brew cask install xquartz
brew install gtk+3 boost
brew install dlib

Then your setup will be fine. I am using without adding Accelerate.framework explicitly.

int soumen
  • 521
  • 5
  • 14