Cross compiling dlib for ARM on Ubuntu

Since I could not find any instruction to compile dlib for ARM (to use it e.g. on a raspberry pi) I decided to write one.

First, install all required packages:
sudo apt-get install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi pkg-config libx11-dev libatlas-base-dev libgtk-3-dev libboost-all-dev build-essential cmake libncurses5-dev gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf

Download dlib and upzip:
wget http://dlib.net/files/dlib-19.8.zip
unzip dlib-19.8.zip

Compile:
cmake -DCMAKE_C_FLAGS=”-O3 -mfpu=neon -fprofile-use -DENABLE_NEON” -DNEON=ON -DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabihf-g++ -DCMAKE_CXX_FLAGS=”-std=c++11″ –build –config Release ..

make

sudo make install

3 thoughts on “Cross compiling dlib for ARM on Ubuntu”

  1. Dear padmalcom,
    I try to “mkdir build” the cd “build” and follow your intrusions to build but got the below error:
    dlib-19.8/build$ cmake -DCMAKE_C_FLAGS=”-O3 -mfpu=neon -fprofile-use -DENABLE_NEON” -DNEON=ON -DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabihf-g++ -DCMAKE_CXX_FLAGS=”-std=c++11″ –build –config Release ..
    Parse error in command line argument: -DENABLE_NEON”
    Should be: VAR:type=value
    CMake Error: No cmake script provided.
    CMake Error: Problem processing arguments. Aborting.”

    Any suggestion?

    Thanks and best regards
    He Wei

  2. Hello, I have followed your tutorial to cross-compile dlib for arm. However, i am struck with an make error. Please take a look:
    In file included from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads.h:22:0,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/matrix_la.h:25,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix.h:11,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/point_transforms.h:9,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry.h:10,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/image_dataset_metadata.h:8,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/image_dataset_metadata.cpp:6:
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/thread_pool_extension.h:456:26: error: ‘exception_ptr’ in namespace ‘std’ does not name a type
    mutable std::exception_ptr eptr; // non-null if the task threw an exception
    ^
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/thread_pool_extension.h: In constructor ‘dlib::thread_pool_implementation::task_state_type::task_state_type()’:
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/thread_pool_extension.h:415:107: error: class ‘dlib::thread_pool_implementation::task_state_type’ does not have any field named ‘eptr’
    task_state_type() : is_being_processed(false), task_id(0), next_task_id(2), arg1(0), arg2(0), eptr(nullptr) {}
    ^
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/thread_pool_extension.h: In member function ‘void dlib::thread_pool_implementation::task_state_type::propagate_exception() const’:
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/thread_pool_extension.h:460:21: error: ‘eptr’ was not declared in this scope
    if (eptr)
    ^
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/thread_pool_extension.h:462:32: error: unable to deduce ‘auto’ from ‘eptr’
    auto tmp = eptr;
    ^
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/thread_pool_extension.h:464:21: error: ‘rethrow_exception’ is not a member of ‘std’
    std::rethrow_exception(tmp);
    ^
    In file included from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/parallel_for_extension.h:9:0,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads.h:24,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/matrix_la.h:25,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix.h:11,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/point_transforms.h:9,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry.h:10,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/image_dataset_metadata.h:8,
    from /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/image_dataset_metadata.cpp:6:
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/async.h: In lambda function:
    /home/rohit/Desktop/HiSillicon/dlib/dlib/data_io/../geometry/../matrix/../threads/async.h:73:37: error: ‘current_exception’ is not a member of ‘std’
    prom->set_exception(std::current_exception());
    ^
    dlib/CMakeFiles/dlib.dir/build.make:326: recipe for target ‘dlib/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o’ failed
    make[2]: *** [dlib/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o] Error 1
    CMakeFiles/Makefile2:85: recipe for target ‘dlib/CMakeFiles/dlib.dir/all’ failed
    make[1]: *** [dlib/CMakeFiles/dlib.dir/all] Error 2
    Makefile:149: recipe for target ‘all’ failed
    make: *** [all] Error 2

    My cmake command is exactly same as yours. Any help is hugely appreciated. Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *