caffe2 ubuntu16.04 安装错误 cannot find -lopencv_dep_cudart

[ 54%] Linking CXX shared library libCaffe2_CPU.so 
/usr/bin/ld: cannot find -lopencv_dep_cudart 
collect2: error: ld returned 1 exit status 
caffe2/CMakeFiles/Caffe2_CPU.dir/build.make:4245: recipe for target ‘caffe2/libCaffe2_CPU.so’ failed 
make[2]:  *  [caffe2/libCaffe2_CPU.so] Error 1 
CMakeFiles/Makefile2:2684: recipe for target ‘caffe2/CMakeFiles/Caffe2_CPU.dir/all’ failed 
make[1]:  *  [caffe2/CMakeFiles/Caffe2_CPU.dir/all] Error 2 
Makefile:138: recipe for target ‘all’ failed 

make: * [all] Error 2


在makefile 中将cmake ..更改为

     

     cmake -D CUDA_USE_STATIC_CUDA_RUNTIME=OFF .. 

或者在CMakeLists中添加

          set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)


重新make即可


当然也可以按照下面的做法:将方式1改写为方式2,就可以了,而非全部链接

方式一:

[cpp]  view plain  copy
  1. cmake_minimum_required(VERSION 3.6)  
  2. project(hello)  
  3. set(CMAKE_CXX_STANDARD 11)  
  4. find_package(OpenCV REQUIRED)  
  5. include_directories( ${OpenCV_INCLUDE_DIRS})
  6. set(SOURCE_FILES main.cpp)  
  7. add_executable(hello ${SOURCE_FILES})  
  8. target_link_libraries(hello ${OpenCV_LIBRARIES})  //链接了所有的lib文件


方式二(推荐):

[cpp]  view plain  copy
  1. cmake_minimum_required(VERSION 3.6)  
  2. project(hello)  
  3. set(CMAKE_CXX_STANDARD 11)  
  4. find_package(OpenCV REQUIRED)  
  5. set(SOURCE_FILES main.cpp)  
  6. include_directories( ${OpenCV_INCLUDE_DIRS})
  7. add_executable(hello ${SOURCE_FILES})  
  8. # 第三方库位置可以通过命令pkg-config --cflags --libs opencv查看  
  9. target_link_libraries(hello  -lopencv_core   -lopencv_highgui -lopencv_imgproc  -lopencv_video )    

你可能感兴趣的:(caffe)