2017-10-10 22 views
0

このコマンドでDlibをグローバル共有ライブラリとしてコンパイルしてインストールしましたsudo cmake --build . --target install --config Release次に、/usr/local/include/dlibに必要なファイルがあることを確認するためにダブルチェックします。 グローバルにインストールされたDlibでDlibサンプルをコンパイルできない

私は共有ライブラリでコンパイルするdlib/examples/CMakeLists.txtビットを変更し、ほとんどの株は以下の元であるオリジナルCMakeLists.txtの

cmake_minimum_required(VERSION 2.8.12) 
project(examples) 

# Modified lines [1] 
#include(../dlib/cmake) 
find_package(dlib REQUIRED) 
include_directories(${dlib_INCLUDE_DIRS}) 

macro(add_example name) 
    add_executable(${name} ${name}.cpp) 
    # Modified lines [2] 
    #target_link_libraries(${name} dlib::dlib) 
    target_link_libraries(${name} ${dlib_INCLUDE_LIBS}) 
endmacro() 

macro(add_gui_example name) 
    if (DLIB_NO_GUI_SUPPORT) 
     message("No GUI support, so we won't build the ${name} example.") 
    else() 
     add_example(${name}) 
    endif() 
endmacro() 

add_gui_example(face_detection_ex) 

残りが除去されます。ここで

は、出力ログ(repetative部品を取り外す)の一部です:

[ 50%] Building CXX object CMakeFiles/face_detection_ex.dir/face_detection_ex.cpp.o 
[100%] Linking CXX executable face_detection_ex 
CMakeFiles/face_detection_ex.dir/face_detection_ex.cpp.o: In function `dlib::entropy_decoder_model_kernel_5<257ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)': 
face_detection_ex.cpp:(.text._ZN4dlib30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EE6decodeERm[_ZN4dlib30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EE6decodeERm]+0x175): undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)' 

face_detection_ex.cpp:(.text._ZN4dlib30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EE6decodeERm[_ZN4dlib30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EE6decodeERm]+0x215): undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)' 

face_detection_ex.cpp:(.text._ZNK4dlib10png_loader9get_imageINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_[_ZNK4dlib10png_loader9get_imageINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_]+0x7a): undefined reference to `dlib::png_loader::is_gray() const' 

face_detection_ex.cpp:(.text._ZN4dlib30entropy_decoder_model_kernel_5ILm256ENS_24entropy_decoder_kernel_2ELm200000ELm4EE6decodeERm[_ZN4dlib30entropy_decoder_model_kernel_5ILm256ENS_24entropy_decoder_kernel_2ELm200000ELm4EE6decodeERm]+0x175): undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)' 

face_detection_ex.cpp:(.text._ZNK4dlib24compress_stream_kernel_1INS_30entropy_encoder_model_kernel_5ILm257ENS_24entropy_encoder_kernel_2ELm200000ELm4EEENS_30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EEENS_5crc32EE10decompressERSiRSo[_ZNK4dlib24compress_stream_kernel_1INS_30entropy_encoder_model_kernel_5ILm257ENS_24entropy_encoder_kernel_2ELm200000ELm4EEENS_30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EEENS_5crc32EE10decompressERSiRSo]+0x7a0): undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)' 

face_detection_ex.cpp:(.text._ZNK4dlib24compress_stream_kernel_1INS_30entropy_encoder_model_kernel_5ILm257ENS_24entropy_encoder_kernel_2ELm200000ELm4EEENS_30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EEENS_5crc32EE10decompressERSiRSo[_ZNK4dlib24compress_stream_kernel_1INS_30entropy_encoder_model_kernel_5ILm257ENS_24entropy_encoder_kernel_2ELm200000ELm4EEENS_30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EEENS_5crc32EE10decompressERSiRSo]+0x7bf): undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)' 

face_detection_ex.cpp:(.text._ZNK4dlib24compress_stream_kernel_1INS_30entropy_encoder_model_kernel_5ILm257ENS_24entropy_encoder_kernel_2ELm200000ELm4EEENS_30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EEENS_5crc32EE10decompressERSiRSo[_ZNK4dlib24compress_stream_kernel_1INS_30entropy_encoder_model_kernel_5ILm257ENS_24entropy_encoder_kernel_2ELm200000ELm4EEENS_30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EEENS_5crc32EE10decompressERSiRSo]+0x895): undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()' 

CMakeFiles/face_detection_ex.dir/face_detection_ex.cpp.o: In function `dlib::get_serialized_frontal_faces[abi:cxx11]()': 
face_detection_ex.cpp:(.text._ZN4dlib28get_serialized_frontal_facesB5cxx11Ev[_ZN4dlib28get_serialized_frontal_facesB5cxx11Ev]+0x9f1c): undefined reference to `dlib::base64::~base64()' 
CMakeFiles/face_detection_ex.dir/face_detection_ex.cpp.o: In function `void dlib::load_dng<dlib::array2d<unsigned char, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<unsigned char, dlib::memory_manager_stateless_kernel_1<char> >&, std::istream&)': 
face_detection_ex.cpp:(.text._ZN4dlib8load_dngINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_RSi[_ZN4dlib8load_dngINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_RSi]+0x2f68): undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)' 
face_detection_ex.cpp:(.text._ZN4dlib8load_dngINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_RSi[_ZN4dlib8load_dngINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_RSi]+0x342d): undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)' 
face_detection_ex.cpp:(.text._ZN4dlib8load_dngINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_RSi[_ZN4dlib8load_dngINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_RSi]+0x3c03): undefined reference to `dlib::entropy_decoder_kernel_2::set_stream(std::istream&)' 
face_detection_ex.cpp:(.text._ZN4dlib8load_dngINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_RSi[_ZN4dlib8load_dngINS_7array2dIhNS_33memory_manager_stateless_kernel_1IcEEEEEEvRT_RSi]+0x43a0): undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()' 

face_detection_ex.cpp:(.text.startup+0x3e2): undefined reference to `dlib::image_window::image_window()' 
face_detection_ex.cpp:(.text.startup+0x98a): undefined reference to `dlib::image_window::clear_overlay()' 
face_detection_ex.cpp:(.text.startup+0xac3): undefined reference to `dlib::scrollable_region::set_total_rect_size(unsigned long, unsigned long)' 

collect2: error: ld returned 1 exit status 
CMakeFiles/face_detection_ex.dir/build.make:94: recipe for target 'face_detection_ex' failed 
make[2]: *** [face_detection_ex] Error 1 
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/face_detection_ex.dir/all' failed 
make[1]: *** [CMakeFiles/face_detection_ex.dir/all] Error 2 
Makefile:83: recipe for target 'all' failed 
make: *** [all] Error 2 
+0

これは、すべて間違っています。 dlibのCMakeLists.txtを変更して共有ライブラリを作成しないでください。普通のようにコンパイルすれば、それが構築されます。さらに、古い$ {dlib_INCLUDE_LIBS}ではなく、最新のcmake dlib :: dlibターゲットを使用する必要があります。 –

+0

Err、ごめんなさい。あなたの質問を間違えて読んでください:/本当に 'include(../ dlib/cmake)'行を 'find_package(dlib)'に変更すれば動作します。 –

+0

@DavisKingあなたは 'target_link_libraries($ {name} $ {dlib_LIBS})'と 'include_directory($ {dlib_INCLUDE_DIRS})'を必要としないことを意味しますか?私はCMakeLists.txtを実行して自分の質問に答えました。 – hirikarate

答えて

0

私はタイプミスtarget_link_libraries(my_target ${dlib_INCLUDE_LIBS})を作ったので、それはだ、その理由を発見しました。一方、dlib_LIBRARIESまたはdlib_LIBSでなければならず、dlib_INCLUDE_LIBSではありません。

正しいCMakeLists.txtは次のとおりです。

cmake_minimum_required(VERSION 2.8.12) 
project(examples) 

# Fix error "cannot find -lopencv_dep_cudart" 
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF) 

# Modified lines [1] 
# include(../dlib/cmake) 
find_package(dlib REQUIRED) 
include_directories(${dlib_INCLUDE_DIRS}) 

macro(add_example name) 
    add_executable(${name} ${name}.cpp) 
    # Modified lines [2] 
    # target_link_libraries(${name} dlib::dlib) 
    target_link_libraries(${name} ${dlib_LIBS}) 
endmacro() 

macro(add_gui_example name) 
    if (DLIB_NO_GUI_SUPPORT) 
     message("No GUI support, so we won't build the ${name} example.") 
    else() 
     add_example(${name}) 
    endif() 
endmacro() 

add_gui_example(face_detection_ex) 
関連する問題