在 mac os 上编译 dlib

Posted

技术标签:

【中文标题】在 mac os 上编译 dlib【英文标题】:compile dlib on mac os 【发布时间】:2017-09-27 05:31:33 【问题描述】:

我在 macOS 上编译了 dlib c++ 代码。这是我键入 cmake 时的结果

build cmake ..
-- The C compiler identification is AppleClang 7.3.0.7030029
-- The CXX compiler identification is AppleClang 7.3.0.7030029
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building a C++11 test project to see if your compiler supports C++11
-- ********** Your compiler failed to build a C++11 project.  C++11 is required to use all parts of dlib! **********
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Performing Test COMPILER_SUPPORTS_CXX0X
-- Performing Test COMPILER_SUPPORTS_CXX0X - Success
-- C++11 activated (compiler doesn't have full C++11 support).
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Looking for png_create_read_struct
-- Looking for png_create_read_struct - found
-- Looking for jpeg_read_header
-- Looking for jpeg_read_header - found
-- Searching for BLAS and LAPACK
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'cblas'
--   No package 'cblas' found
-- Checking for module 'lapack'
--   No package 'lapack' found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Found Intel MKL BLAS/LAPACK library
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing:  CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5")
-- *** Dlib CUDA support requires C++11 but your compiler doesn't support it. ***
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/fengshaozhe/Applications/dlib-19.4/examples/build

这对我来说似乎很有效。然后我做了

cmake --build . --config Release

看起来一切都完成了。但是当我尝试像这样运行示例时

./face_landmark_detection_ex

我收到了这个错误

dyld: Library not loaded: libmkl_rt.dylib
  Referenced from: /Users/fengshaozhe/Applications/dlib-19.4/examples/build/./face_landmark_detection_ex
  Reason: image not found
[1]    70386 trace trap  ./face_landmark_detection_ex

有人可以帮帮我吗?

【问题讨论】:

【参考方案1】:

我通过升级 cmake 解决了这个问题。最后的cmake版本是3.5,当前的cmake版本是3.8。 但是我不完全知道为什么升级cmake可以解决这个问题。 谁能告诉我原因?

【讨论】:

使用 make 3.15 但仍然有这个问题。

以上是关于在 mac os 上编译 dlib的主要内容,如果未能解决你的问题,请参考以下文章

在 Mac OS 上编译 FFmpeg

mac os x yosemite下如何编译milton?

C++ 在 Mac OS X 上编译代码并在 Linux x86 上运行

在Mac OSX上编译NASM

Mac上编译C++报错

如何使用 GCC-MP-4.7 在 OS X 上编译 ASL?