This blog takes a deeper dive into building DLIB from source, in reference to the following hackster project:
http://avnet.me/vitis-ai-1.3-headpose
The first thing to do is to download the source tar bar from dlib.net (I tested with version 19.21).
wget http://dlib.net/files/dlib-19.21.tar.bz2
tar xvf dlib-19.21.tar.bz2
cd dlib-19.21
Next, cmake is used to build the dlib package:
mkdir build
cd build
cmake ..
cmake --build . --config Release
Finally, the compiled dlib package need to be installed for use with C++ applications.
sudo make install
And installed for use with python.
cd ..
python3 setup.py install
Humm ... for some reason, this is rebuilding everything ... there must be another way to do this ...
For reference, I have provided the output for my build (for use with C++ applications):
~/dlib-19.21/build# cmake ..
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /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: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CMake version: 3.15.3
-- Compiling dlib version: 19.21.0
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found X11: /usr/include
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found system copy of libpng: /usr/lib/libpng.so;/usr/lib/libz.so
-- Found system copy of libjpeg: /usr/lib/libjpeg.so
-- Searching for BLAS and LAPACK
-- Searching for BLAS and LAPACK
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- 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
*****************************************************************************
*** No BLAS library found so using dlib's built in BLAS. However, if you ***
*** install an optimized BLAS such as OpenBLAS or the Intel MKL your code ***
*** will run faster. On Ubuntu you can install OpenBLAS by executing: ***
*** sudo apt-get install libopenblas-dev liblapack-dev ***
*** Or you can easily install OpenBLAS from source by downloading the ***
*** source tar file from http://www.openblas.net, extracting it, and ***
*** running: ***
*** make; sudo make install ***
*****************************************************************************
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")
-- DID NOT FIND CUDA
-- Disabling CUDA support for dlib. DLIB WILL NOT USE CUDA
-- C++11 activated.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/root/dlib-19.21/build
~/dlib-19.21/build# cmake --build . --config Release
Scanning dependencies of target dlib
[ 1%] Building CXX object dlib/CMakeFiles/dlib.dir/base64/base64_kernel_1.cpp.o
[ 3%] Building CXX object dlib/CMakeFiles/dlib.dir/bigint/bigint_kernel_1.cpp.o
[ 5%] Building CXX object dlib/CMakeFiles/dlib.dir/bigint/bigint_kernel_2.cpp.o
[ 6%] Building CXX object dlib/CMakeFiles/dlib.dir/bit_stream/bit_stream_kernel_1.cpp.o
[ 8%] Building CXX object dlib/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_1.cpp.o
[ 10%] Building CXX object dlib/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_2.cpp.o
[ 11%] Building CXX object dlib/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_1.cpp.o
[ 13%] Building CXX object dlib/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_2.cpp.o
[ 15%] Building CXX object dlib/CMakeFiles/dlib.dir/md5/md5_kernel_1.cpp.o
[ 16%] Building CXX object dlib/CMakeFiles/dlib.dir/tokenizer/tokenizer_kernel_1.cpp.o
[ 18%] Building CXX object dlib/CMakeFiles/dlib.dir/unicode/unicode.cpp.o
[ 20%] Building CXX object dlib/CMakeFiles/dlib.dir/test_for_odr_violations.cpp.o
[ 22%] Building CXX object dlib/CMakeFiles/dlib.dir/sockets/sockets_kernel_1.cpp.o
[ 23%] Building CXX object dlib/CMakeFiles/dlib.dir/bsp/bsp.cpp.o
[ 25%] Building CXX object dlib/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_1.cpp.o
[ 27%] Building CXX object dlib/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_2.cpp.o
[ 28%] Building CXX object dlib/CMakeFiles/dlib.dir/dir_nav/dir_nav_extensions.cpp.o
[ 30%] Building CXX object dlib/CMakeFiles/dlib.dir/linker/linker_kernel_1.cpp.o
[ 32%] Building CXX object dlib/CMakeFiles/dlib.dir/logger/extra_logger_headers.cpp.o
[ 33%] Building CXX object dlib/CMakeFiles/dlib.dir/logger/logger_kernel_1.cpp.o
[ 35%] Building CXX object dlib/CMakeFiles/dlib.dir/logger/logger_config_file.cpp.o
[ 37%] Building CXX object dlib/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_1.cpp.o
[ 38%] Building CXX object dlib/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_2.cpp.o
[ 40%] Building CXX object dlib/CMakeFiles/dlib.dir/sockets/sockets_extensions.cpp.o
[ 42%] Building CXX object dlib/CMakeFiles/dlib.dir/sockets/sockets_kernel_2.cpp.o
[ 44%] Building CXX object dlib/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf.cpp.o
[ 45%] Building CXX object dlib/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf_unbuffered.cpp.o
[ 47%] Building CXX object dlib/CMakeFiles/dlib.dir/server/server_kernel.cpp.o
[ 49%] Building CXX object dlib/CMakeFiles/dlib.dir/server/server_iostream.cpp.o
[ 50%] Building CXX object dlib/CMakeFiles/dlib.dir/server/server_http.cpp.o
[ 52%] Building CXX object dlib/CMakeFiles/dlib.dir/threads/multithreaded_object_extension.cpp.o
[ 54%] Building CXX object dlib/CMakeFiles/dlib.dir/threads/threaded_object_extension.cpp.o
[ 55%] Building CXX object dlib/CMakeFiles/dlib.dir/threads/threads_kernel_1.cpp.o
[ 57%] Building CXX object dlib/CMakeFiles/dlib.dir/threads/threads_kernel_2.cpp.o
[ 59%] Building CXX object dlib/CMakeFiles/dlib.dir/threads/threads_kernel_shared.cpp.o
[ 61%] Building CXX object dlib/CMakeFiles/dlib.dir/threads/thread_pool_extension.cpp.o
[ 62%] Building CXX object dlib/CMakeFiles/dlib.dir/threads/async.cpp.o
[ 64%] Building CXX object dlib/CMakeFiles/dlib.dir/timer/timer.cpp.o
[ 66%] Building CXX object dlib/CMakeFiles/dlib.dir/stack_trace.cpp.o
[ 67%] Building CXX object dlib/CMakeFiles/dlib.dir/cuda/cpu_dlib.cpp.o
[ 69%] Building CXX object dlib/CMakeFiles/dlib.dir/cuda/tensor_tools.cpp.o
[ 71%] Building CXX object dlib/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o
[ 72%] Building CXX object dlib/CMakeFiles/dlib.dir/data_io/mnist.cpp.o
[ 74%] Building CXX object dlib/CMakeFiles/dlib.dir/global_optimization/global_function_search.cpp.o
[ 76%] Building CXX object dlib/CMakeFiles/dlib.dir/filtering/kalman_filter.cpp.o
In file included from /home/root/dlib-19.21/dlib/filtering/../matrix.h:11,
from /home/root/dlib-19.21/dlib/filtering/kalman_filter.h:7,
from /home/root/dlib-19.21/dlib/filtering/kalman_filter.cpp:6:
/home/root/dlib-19.21/dlib/filtering/../matrix/matrix_la.h: In function 'long int dlib::svd4(dlib::svd_u_mode, bool, const dlib:
:matrix_exp<EXP>&, dlib::matrix<typename EXP::type, uM, uN, MM1, L1>&, dlib::matrix<typename EXP::type, qN, qX, MM2, L1>&, dlib:
:matrix<typename EXP::type, vM, vN, MM3, L1>&) [with EXP = dlib::matrix_op<dlib::op_trans<dlib::matrix_op<dlib::op_trans<dlib::m
atrix<double, 1, 2, dlib::memory_manager_stateless_kernel_1<char>, dlib::row_major_layout> > > > >; long int qN = 1; long int qX
= 1; long int uM = 1; long int uN = 1; long int vM = 2; long int vN = 1; MM1 = dlib::memory_manager_stateless_kernel_1<char>; M
M2 = dlib::memory_manager_stateless_kernel_1<char>; MM3 = dlib::memory_manager_stateless_kernel_1<char>; L1 = dlib::row_major_la
yout]':
/home/root/dlib-19.21/dlib/filtering/../matrix/matrix_la.h:225:32: warning: iteration 1 invokes undefined behavior [-Waggressive
-loop-optimizations]
225 | y = abs(q(i)) + abs(e(i));
| ~~~^~~~~~
/home/root/dlib-19.21/dlib/filtering/../matrix/matrix_la.h:163:20: note: within this loop
163 | for (i=0; i<n; i++)
| ~^~
[ 77%] Building CXX object dlib/CMakeFiles/dlib.dir/svm/auto.cpp.o
[ 79%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o
[ 81%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_widgets/widgets.cpp.o
[ 81%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_widgets/widgets.cpp.o
[ 83%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_widgets/drawable.cpp.o
[ 84%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_widgets/canvas_drawing.cpp.o
[ 86%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_widgets/style.cpp.o
[ 88%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_widgets/base_widgets.cpp.o
[ 89%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_1.cpp.o
[ 91%] Building CXX object dlib/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_2.cpp.o
[ 93%] Building CXX object dlib/CMakeFiles/dlib.dir/image_loader/png_loader.cpp.o
[ 94%] Building CXX object dlib/CMakeFiles/dlib.dir/image_saver/save_png.cpp.o
[ 96%] Building CXX object dlib/CMakeFiles/dlib.dir/image_loader/jpeg_loader.cpp.o
[ 98%] Building CXX object dlib/CMakeFiles/dlib.dir/image_saver/save_jpeg.cpp.o
[100%] Linking CXX static library libdlib.a
[100%] Built target dlib