2016-12-22 216 views
1

我想與Dlib一起進行面部標誌檢測,並試圖將它安裝在我的macOS Sierra上。我按照main GitHub Repo for dlib中的說明操作。macOS - 麻煩安裝dlib

我第一次執行沒有錯誤下面進入實例文件夾後:

mkdir build; cd build; cmake .. ; cmake --build . 

恢復到上一級目錄,我執行以下操作:

sudo python2.7 setup.py install 

這之後遇到20+錯誤完成38%:

[ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/timer/timer.cpp.o 
[ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/stack_trace.cpp.o 
[ 36%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o 
In file included from /Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/fonts.cpp:14: 
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:313:21: error: use of undeclared identifier 'XAllocColor' 
        XAllocColor(d, cmap, &xcol); 
        ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:319:36: error: use of undeclared identifier 'XmbTextExtents'; did you mean 'XTextExtents'? 
          return XmbTextExtents(fs, str, len, ink, logical); 
            ^~~~~~~~~~~~~~ 
            XTextExtents 
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:318:43: note: 'XTextExtents' declared here 
         inline static int XTextExtents (XFontSet fs, char *str, int len, XRectangle *ink, XRectangle *logical){ 
             ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:322:36: error: use of undeclared identifier 'XwcTextExtents'; did you mean 'XTextExtents'? 
          return XwcTextExtents(fs, str, len, ink, logical); 
            ^~~~~~~~~~~~~~ 
            XTextExtents 
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:321:43: note: 'XTextExtents' declared here 
         inline static int XTextExtents (XFontSet fs, wchar_t *str, int len, XRectangle *ink, XRectangle *logical){ 
             ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:325:29: error: use of undeclared identifier 'XmbDrawString'; did you mean 'XDrawString'? 
          XmbDrawString(d, w, fs, gc, x, y, str, num_bytes); 
          ^~~~~~~~~~~~~ 
          XDrawString 
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:324:44: note: 'XDrawString' declared here 
         inline static void XDrawString(Display *d, Window w, XFontSet fs, GC gc, int x, int y, char *str, int num_bytes){ 
             ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:328:29: error: use of undeclared identifier 'XwcDrawString'; did you mean 'XDrawString'? 
          XwcDrawString(d, w, fs, gc, x, y, str, num_bytes); 
          ^~~~~~~~~~~~~ 
          XDrawString 
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:327:44: note: 'XDrawString' declared here 
         inline static void XDrawString(Display *d, Window w, XFontSet fs, GC gc, int x, int y, wchar_t *str, int num_bytes){ 
             ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:334:29: error: use of undeclared identifier 'XOpenDisplay' 
         d = XOpenDisplay(NULL); 
          ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:337:33: error: use of undeclared identifier 'XOpenDisplay' 
          d = XOpenDisplay(":0.0"); 
           ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:369:29: error: use of undeclared identifier 'XFreeFontSet' 
          XFreeFontSet(d, fs); 
          ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:371:30: error: use of undeclared identifier 'XCreateFontSet' 
         fs = XCreateFontSet(d, fontset, &mlist, &mcount, &def_str); 
          ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:376:34: error: use of undeclared identifier 'XExtentsOfFontSet' 
         extent = XExtentsOfFontSet(fs); 
           ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:379:25: error: use of undeclared identifier 'XFreeStringList'; did you mean 'XwcFreeStringList'? 
         XFreeStringList(mlist); 
         ^~~~~~~~~~~~~~~ 
         XwcFreeStringList 
/Users/Ajay/anaconda/include/X11/Xutil.h:777:13: note: 'XwcFreeStringList' declared here 
extern void XwcFreeStringList(
      ^
In file included from /Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/fonts.cpp:14: 
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:379:41: error: cannot initialize a parameter of type 'wchar_t **' with an lvalue of type 'char **' 
         XFreeStringList(mlist); 
             ^~~~~ 
/Users/Ajay/anaconda/include/X11/Xutil.h:781:1: note: passing argument to parameter here 
); 
^ 
In file included from /Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/fonts.cpp:14: 
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:388:29: error: use of undeclared identifier 'XFreeGC' 
          XFreeGC(d, gc); 
          ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:389:29: error: use of undeclared identifier 'XFreePixmap' 
          XFreePixmap(d, pix); 
          ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:393:103: error: use of undeclared identifier 'XDefaultDepth' 
         pix = XCreatePixmap(d, DefaultRootWindow(d), pix_width_prev, pix_height_prev, XDefaultDepth(d, DefaultScreen(d))); 
                            ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:394:30: error: use of undeclared identifier 'XCreateGC' 
         gc = XCreateGC(d, pix, 0, NULL); 
          ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:398:21: error: use of undeclared identifier 'XSetForeground' 
        XSetForeground(d, gc, backcolor); 
        ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:399:21: error: use of undeclared identifier 'XSetBackground' 
        XSetBackground(d, gc, backcolor); 
        ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:400:21: error: use of undeclared identifier 'XFillRectangle' 
        XFillRectangle(d, pix, gc, 0, 0, width, height); 
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=] 
20 errors generated. 
make[2]: *** [dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o] Error 1 
make[1]: *** [dlib_build/CMakeFiles/dlib.dir/all] Error 2 
make: *** [all] Error 2 
error: cmake build failed! 

展望一下,我有th感覺有一個小的路徑(python),我需要改變以使所有的東西都起作用。參考a similar problem,他改變了CMakeCache.txt中的一些路徑,但我不確定哪一行/部分。此外,還有4個CMakeCache.txt文件。我應該更換哪一個(如果有的話)?

Ajays-MacBook-Pro:dlib Ajay$ find . -name "CMakeCache.txt" 
./examples/build/CMakeCache.txt 
./examples/build/cpp11_test_build/CMakeCache.txt 
./tools/python/build/CMakeCache.txt 
./tools/python/build/cpp11_test_build/CMakeCache.txt 

有沒有其他解決方案呢?我該怎麼辦?任何幫助,將不勝感激!

+1

你安裝了XQuartz嗎? –

+0

你有沒有研究過這個問題?我有同樣的問題 – redrubia

回答

0

我不能使用,因爲安裝在我的計算機上的多個Python版本DLIB。 Macbook Pro(2014)預裝了python2.7.10,應該更新而不是。如果需要更新的版本,則需要與v2.7一起安裝。我使用了anaconda並在我的電腦上安裝了python3.5。但是,這似乎是問題中提到的問題的根源。一旦Anaconda和python3.5被卸載,Dlib開始工作,沒有錯誤。原因不明,但仍然是一個令人滿意的工作。

1

見我的回答here

長話短說,你可以得到這個問題even with xQuartz installed

在Git中的最新版本似乎工作,但PyPi存儲庫尚未更新。

在此之前,使用以下命令:

git clone https://github.com/davisking/dlib.git 
cd dlib 
pip install .