Compiling dlib on OS X

早过忘川 提交于 2019-12-08 02:56:38

问题


I try to use dlib in Qt project on OS X. So, in this try I did following:

In dlib root:

cd examples
mkdir build
cd build
cmake ..
cmake --build . --config Release

In dlib root:

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/Users/user/dlib_build
cmake --build . --config Release --target install

.pro file:

INCLUDEPATH += /Users/user/dlib_build/include
LIBS += -L/Users/user/dlib_build/lib
LIBS += -ldlib

main.cpp:

//...
frontal_face_detector detector = get_frontal_face_detector();
//...

Compile output:

Undefined symbols for architecture x86_64:
"_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

How can I solve this and use dlib with Qt on OS X?


回答1:


The right solution is to add missing libraries for linking. When Dlib was build - it found some BLAS library and enabled BLAS support. To find this library - take a look at pkgconfig file from dlib that is located at /Users/user/dlib_build/lib/pkgconfig, it will have line like "Libs: -L${libdir} -ldlib" Qt does not manage such dependencies automatically, so you should add blas libraries by hand

The other (simple) solution is to build dlib without BLAS/LAPACK support: In dlib root:

mkdir build
cd build
cmake .. -DDLIB_USE_BLAS=OFF -DDLIB_USE_LAPACK=OFF -DCMAKE_INSTALL_PREFIX=/Users/user/dlib_build
cmake --build . --config Release --target install



回答2:


add framework accelerate is fine

if you use cmake, add:

target_link_libraries(your_app "-framework accelerate")

if you use xcode, add accelerate directly.



来源:https://stackoverflow.com/questions/38156075/compiling-dlib-on-os-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!