【Clion-Ubuntu-dlib】运行一个dlib案例(一)(如何在clion编译器中配置CMakeLists)

目录

 

第一步:新建一个dlib项目

第二步:运行一个案例hello world

第四步:main写完整

第五步:编译运行

第六步:其他问题

第七步:更多问题有待补充


第一步:新建一个dlib项目

【Clion-Ubuntu-dlib】运行一个dlib案例(一)(如何在clion编译器中配置CMakeLists)_第1张图片

第二步:运行一个案例hello world

【Clion-Ubuntu-dlib】运行一个dlib案例(一)(如何在clion编译器中配置CMakeLists)_第2张图片

第三步:配置CMakeList

cmake_minimum_required(VERSION 2.8)
project(cpp_eval)

set(CMAKE_CXX_STANDARD 11)

add_executable(cpp_eval main.cpp)

set(pathToDlib /media/luckynote/Tool/face-recognition/dlib-19.15.99/)

include(${pathToDlib}/dlib/cmake)

target_link_libraries(cpp_eval dlib::dlib)

第四步:main写完整

说明:这里笔者只导入dlib的头文件进行编译,如果不报错误,则说明dlib就可以正常进行编译运行了。

#include  
#include  
using namespace dlib; 
int main() 
{ 
    std::cout << "Hello, World!" << std::endl; 
    return 0; 
}

第五步:编译运行

【Clion-Ubuntu-dlib】运行一个dlib案例(一)(如何在clion编译器中配置CMakeLists)_第3张图片

第六步:其他问题

若CMakeList配置有问题,如忘记 include(${pathToDlib}/dlib/cmake) 和 target_link_libraries(cpp_eval dlib::dlib) ,则会报出如下错误。

CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘__static_initialization_and_destruction_0(int, int)’中:
/usr/local/include/dlib/test_for_odr_violations.h:24:对‘USER_ERROR__inconsistent_build_configuration__see_dlib_faq_1_’未定义的引用
/usr/local/include/dlib/test_for_odr_violations.h:51:对‘DLIB_VERSION_MISMATCH_CHECK__EXPECTED_VERSION_19_15_99’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘dlib::lapack::binding::gesdd(char, int, int, double*, int, double*, double*, int, double*, int, double*, int, int*)’中:
/usr/local/include/dlib/matrix/lapack/gesdd.h:38:对‘dgesdd_’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘dlib::lapack::binding::gesvd(char, char, int, int, double*, int, double*, double*, int, double*, int, double*, int)’中:
/usr/local/include/dlib/matrix/lapack/gesvd.h:38:对‘dgesvd_’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘dlib::blas_bindings::cblas_gemm(dlib::blas_bindings::CBLAS_ORDER, dlib::blas_bindings::CBLAS_TRANSPOSE, dlib::blas_bindings::CBLAS_TRANSPOSE, int, int, int, double, double const*, int, double const*, int, double, double*, int)’中:
/usr/local/include/dlib/matrix/matrix_blas_bindings.h:219:对‘cblas_dgemm’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘dlib::locally_change_current_dir::locally_change_current_dir(std::__cxx11::basic_string, std::allocator > const&)’中:
/usr/local/include/dlib/misc_api/misc_api_shared.h:22:对‘dlib::get_current_dir[abi:cxx11]()’未定义的引用
/usr/local/include/dlib/misc_api/misc_api_shared.h:23:对‘dlib::set_current_dir(std::__cxx11::basic_string, std::allocator > const&)’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘dlib::locally_change_current_dir::revert()’中:
/usr/local/include/dlib/misc_api/misc_api_shared.h:42:对‘dlib::set_current_dir(std::__cxx11::basic_string, std::allocator > const&)’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘dlib::file::file(std::__cxx11::basic_string, std::allocator > const&)’中:
/usr/local/include/dlib/dir_nav/dir_nav_kernel_2.h:104:对‘dlib::file::init(std::__cxx11::basic_string, std::allocator > const&)’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘std::vector >, std::allocator > > > dlib::load_image_dataset >, dlib::memory_manager_stateless_kernel_1 > >(dlib::array >, dlib::memory_manager_stateless_kernel_1 >&, std::vector >, std::allocator > > >&, dlib::image_dataset_file const&, std::vector, std::allocator >, std::allocator, std::allocator > > >&)’中:
/usr/local/include/dlib/data_io/load_image_dataset.h:354:对‘dlib::image_dataset_metadata::load_image_dataset_metadata(dlib::image_dataset_metadata::dataset&, std::__cxx11::basic_string, std::allocator > const&)’未定义的引用
/usr/local/include/dlib/data_io/load_image_dataset.h:359:对‘dlib::get_parent_directory(dlib::file const&)’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘void dlib::load_png > >(dlib::array2d >&, std::__cxx11::basic_string, std::allocator > const&)’中:
/usr/local/include/dlib/image_loader/png_loader.h:211:对‘dlib::png_loader::png_loader(std::__cxx11::basic_string, std::allocator > const&)’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:211:对‘dlib::png_loader::~png_loader()’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:211:对‘dlib::png_loader::~png_loader()’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘void dlib::load_jpeg > >(dlib::array2d >&, std::__cxx11::basic_string, std::allocator > const&)’中:
/usr/local/include/dlib/image_loader/jpeg_loader.h:96:对‘dlib::jpeg_loader::jpeg_loader(std::__cxx11::basic_string, std::allocator > const&)’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘void dlib::load_dng > >(dlib::array2d >&, std::istream&)’中:
/usr/local/include/dlib/image_loader/image_loader.h:580:对‘dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2()’未定义的引用
/usr/local/include/dlib/image_loader/image_loader.h:581:对‘dlib::entropy_decoder_kernel_2::set_stream(std::istream&)’未定义的引用
/usr/local/include/dlib/image_loader/image_loader.h:580:对‘dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()’未定义的引用
/usr/local/include/dlib/image_loader/image_loader.h:766:对‘dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2()’未定义的引用
/usr/local/include/dlib/image_loader/image_loader.h:767:对‘dlib::entropy_decoder_kernel_2::set_stream(std::istream&)’未定义的引用
/usr/local/include/dlib/image_loader/image_loader.h:766:对‘dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()’未定义的引用
/usr/local/include/dlib/image_loader/image_loader.h:580:对‘dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()’未定义的引用
/usr/local/include/dlib/image_loader/image_loader.h:766:对‘dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘void dlib::png_loader::get_image > >(dlib::array2d >&) const’中:
/usr/local/include/dlib/image_loader/png_loader.h:52:对‘dlib::png_loader::is_gray() const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:56:对‘dlib::png_loader::get_row(unsigned int) const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:64:对‘dlib::png_loader::is_gray() const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:68:对‘dlib::png_loader::get_row(unsigned int) const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:76:对‘dlib::png_loader::is_graya() const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:80:对‘dlib::png_loader::get_row(unsigned int) const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:99:对‘dlib::png_loader::is_graya() const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:103:对‘dlib::png_loader::get_row(unsigned int) const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:122:对‘dlib::png_loader::is_rgb() const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:126:对‘dlib::png_loader::get_row(unsigned int) const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:137:对‘dlib::png_loader::is_rgb() const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:141:对‘dlib::png_loader::get_row(unsigned int) const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:152:对‘dlib::png_loader::is_rgba() const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:159:对‘dlib::png_loader::get_row(unsigned int) const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:171:对‘dlib::png_loader::is_rgba() const’未定义的引用
/usr/local/include/dlib/image_loader/png_loader.h:178:对‘dlib::png_loader::get_row(unsigned int) const’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘void dlib::jpeg_loader::get_image > >(dlib::array2d >&) const’中:
/usr/local/include/dlib/image_loader/jpeg_loader.h:48:对‘dlib::jpeg_loader::is_gray() const’未定义的引用
/usr/local/include/dlib/image_loader/jpeg_loader.h:53:对‘dlib::jpeg_loader::is_rgba() const’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘dlib::entropy_decoder_model_kernel_5<256ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)’中:
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_5.h:422:对‘dlib::entropy_decoder_kernel_2::get_target(unsigned int)’未定义的引用
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_5.h:456:对‘dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)’未定义的引用
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_5.h:503:对‘dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)’未定义的引用
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_5.h:551:对‘dlib::entropy_decoder_kernel_2::get_target(unsigned int)’未定义的引用
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_5.h:553:对‘dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)’未定义的引用
CMakeFiles/cpp_eval.dir/main.cpp.o:在函数‘dlib::entropy_decoder_model_kernel_4<256ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)’中:
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_4.h:348:对‘dlib::entropy_decoder_kernel_2::get_target(unsigned int)’未定义的引用
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_4.h:376:对‘dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)’未定义的引用
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_4.h:422:对‘dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)’未定义的引用
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_4.h:469:对‘dlib::entropy_decoder_kernel_2::get_target(unsigned int)’未定义的引用
/usr/local/include/dlib/entropy_decoder_model/entropy_decoder_model_kernel_4.h:471:对‘dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)’未定义的引用
collect2: error: ld returned 1 exit status
CMakeFiles/cpp_eval.dir/build.make:83: recipe for target 'cpp_eval' failed
make[3]: *** [cpp_eval] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/cpp_eval.dir/all' failed
make[2]: *** [CMakeFiles/cpp_eval.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/cpp_eval.dir/rule' failed
make[1]: *** [CMakeFiles/cpp_eval.dir/rule] Error 2
Makefile:118: recipe for target 'cpp_eval' failed
make: *** [cpp_eval] Error 2

第七步:更多问题有待补充

你可能感兴趣的:(CMake,dlib)