cmakelist 添加第三方库
在libtorch工程中添加一个dcn的库,编译出来的库名字是
/data_4/everyday/0902/snake/snake-refinenet/dcn_cpp_plugin/myinstall/lib/libdcn_v2_cuda_forward_v2.so
下面是完成的总的完成的正确的:
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(snake-refinenet)
SET(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_PREFIX_PATH "/data_4/everyday/0901/pytorch/torch")
find_package(Torch REQUIRED)
set(CMAKE_PREFIX_PATH "/home/yhl/software_install/opencv3.2")
find_package(OpenCV REQUIRED)
#include_directories("/data_4/everyday/0902/snake/snake-refinenet/dcn_cpp_plugin/dcn_v2.h")
#link_directories("/data_4/everyday/0902/snake/snake-refinenet/dcn_cpp_plugin/myinstall/lib/libdcn_v2_cuda_forward_v2.so")
#link_libraries(libdcn_v2_cuda_forward_v2)
set(INC_DIR /data_4/everyday/0902/snake/snake-refinenet/dcn_cpp_plugin)
set(LINK_DIR /data_4/everyday/0902/snake/snake-refinenet/dcn_cpp_plugin/myinstall/lib)
include_directories(${INC_DIR})
link_directories(${LINK_DIR})
link_libraries(dcn_v2_cuda_forward_v2)
add_executable(example-app example-app.cpp refine_det.cpp)
target_link_libraries(example-app "${TORCH_LIBRARIES}")
#target_link_libraries(example-app ${Boost_LIBRARIES})
target_link_libraries(example-app ${OpenCV_LIBS})
target_link_libraries(example-app dcn_v2_cuda_forward_v2)
set_property(TARGET example-app PROPERTY CXX_STANDARD 11)
一开始报错找不到
/usr/bin/ld: 找不到 -llibdcn_v2_cuda_forward_v2
/usr/bin/ld: 找不到 -llibdcn_v2_cuda_forward_v2
原来是要把lib去掉啊
link_libraries(dcn_v2_cuda_forward_v2)
target_link_libraries(example-app dcn_v2_cuda_forward_v2)
好记性不如烂键盘---点滴、积累、进步!