当前位置:网站首页>Compile Caffe's project using cmake
Compile Caffe's project using cmake
2022-06-25 14:47:00 【HELLOWORLD2424】
Use CMake compile Caffe Project
Recently I was compiling a Caffe Project , This dependency is always missing at compile time , That dependency , Here are a few lessons learned .
1. Caffe You have to use CMake To compile
I started with what the author provided Makefile To compile Caffe, As a result, when compiling my project , There will always be no Caffe Dependence , So I've been reporting mistakes .
2. Boost The library cannot be used apt Tool to install
apt-get The installation of tools is simple , Save a lot of trouble , The same is true of me , compile Caffe Time is no problem , But compile later Caffe Project time , There will be many strange problems , Later, I used the source code to install Boost success , The time spent in the middle is simply touching .
3. CMake Precompiled output
I use CLion To compile , Here, I will directly attach build The output of the console , You can see my dependent version below .
/root/clion-2021.3.2/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/root/clion-2021.3.2/bin/ninja/linux/ninja -G Ninja /root/CLionProjects/caffe_classification_demo
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr/local (found version "3.4.5")
-- Found Boost: /usr/local/include (found version "1.63.0") found components: filesystem system
-- Found Protobuf: /usr/local/lib/libprotobuf.so;-lpthread (found version "3.3.0")
Caffe_INCLUDE_DIRS /usr/local/dxai_caffe/src;/usr/local/include;/usr/include;/usr/local/dxai_caffe/build/include;/usr/include/hdf5/serial;/usr/local/include/opencv;/usr/include/x86_64-linux-gnu;/usr/local/dxai_caffe/include
Caffe_LIBRARIES caffe
-- Configuring done
-- Generating done
-- Build files have been written to: /root/CLionProjects/caffe_classification_demo/cmake-build-debug
[Finished]
4. CMakeLists.txt
Here also directly to my CMakeLists.txt Of ,CMakeList.txt Of find_package It's always windy , Not intelligent at all ( Make complaints about , But it may also be that my younger brother is incompetent ). The following is the correct way of writing which I have tried for many days and nights .
cmake_minimum_required(VERSION 3.21)
project(caffe_demo)
set(CMAKE_CXX_STANDARD 14)
# cpu only
option(USE_OPENCV "whether use opencv" ON)
if (USE_OPENCV)
add_definitions(-DUSE_OPENCV)
endif()
option(CPU_ONLY "whether use cpu only" ON)
if(CPU_ONLY)
add_definitions(-DCPU_ONLY)
endif()
# Set the Library Directory
# OpenCV
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
# Boost
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
find_package(Boost REQUIRED COMPONENTS filesystem system) # Said the use of boost Of filesystem Components
include_directories(${Boost_INCLUDE_DIRS})
# protobuf
find_package(Protobuf REQUIRED)
include_directories(${Protobuf_INCLUDE_DIRS})
# glog
SET(GLOG_INC_DIR /usr/local/include)
SET(GLOG_LINK_DIR /usr/local/lib)
include_directories(${GLOG_INC_DIR})
link_directories(${GLOG_LINK_DIR})
link_libraries(glog)
# Caffe
find_package(Caffe REQUIRED)
if (Caffe_FOUND)
message("Caffe_INCLUDE_DIRS ${Caffe_INCLUDE_DIRS}")
message("Caffe_LIBRARIES ${Caffe_LIBRARIES}")
endif ()
include_directories(${Caffe_INCLUDE_DIRS})
add_executable(testDetection testDetection.cpp)
add_executable(detection detection.cpp)
## For the specified bin File add third party link library
TARGET_LINK_LIBRARIES(testDetection ${OpenCV_LIBRARIES})
TARGET_LINK_LIBRARIES(testDetection glog)
TARGET_LINK_LIBRARIES(testDetection ${Caffe_LIBRARIES})
TARGET_LINK_LIBRARIES(detection ${OpenCV_LIBRARIES})
TARGET_LINK_LIBRARIES(detection glog)
TARGET_LINK_LIBRARIES(detection ${Caffe_LIBRARIES})
边栏推荐
- 程序员为什么要软一点?
- How to view the Chrome browser plug-in location
- Open a restaurant
- 两种方法实现pycharm中代码回滚到指定版本(附带截图展示)
- New good friend Pinia, leading the new era of state management
- 网上股票开户安不安全?有谁知道呢
- TSDB在民机行业中的应用
- laravel8实现图片验证码
- Golang project dependency management tool go vendor, go Mod
- 多张动图怎样合成一张gif?仅需三步快速生成gif动画图片
猜你喜欢

112页机器学习-数学基础回顾.pptx

分享自己平時使用的socket多客戶端通信的代碼技術點和軟件使用

Flexible layout (display:flex;) Attribute details

中国电池技术取得重大突破,日韩美都落后了,中国巩固了领先优势

Thymeleaf Usage Summary

2022年广东高考分数线出炉,一个几家欢喜几家愁

【中國海洋大學】考研初試複試資料分享

15 -- 最接近原点的 K 个点

Power automatic test system nsat-8000, accurate, high-speed and reliable power test equipment

Kubernetes understands kubectl/ debugging
随机推荐
【Try to Hack】vulnhub DC1
How to make GIF animation online? Try this GIF online production tool
JS to add elements to the header, or tail of an array
Uniapp icon configuration
分享自己平時使用的socket多客戶端通信的代碼技術點和軟件使用
Uniapp cloud packaging app
Two common ways for orcale to clear table data
【中国海洋大学】考研初试复试资料分享
Master XSS completely from 0 to 1
Shell built-in commands
oracle数据库常用的函数总结
Sigmoid function sigmoid derivation
The best screenshot tool in the world, color absorption tool snipaste
【Try to Hack】vulnhub DC1
About reconnection of STM32 using lan8720a plug-in network cable
Open a restaurant
【Try to Hack】vulhub靶场搭建
For the first time in China, Chinatelecom 5g underground personnel positioning project is officially commercial: it can track the position in real time to ensure operation safety
H5 page graying source code, ie compatible (elegant downgrade provides download browser link)
电源自动测试系统NSAT-8000,精准高速可靠的电源测试设备