当前位置:网站首页>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})
边栏推荐
- Why should programmers be softer?
- Shell operator
- Thymeleaf Usage Summary
- Tencent cloud builds a Socks5 multi IP proxy server to realize the perfect building of a game with a single window and a single IP. Tutorial attached tool "suggestions collection"
- 电源自动测试系统NSAT-8000,精准高速可靠的电源测试设备
- Clinical Chemistry | 张建中/徐健开发幽门螺杆菌单细胞精准诊疗技术
- NBD Network Block Device
- Partager les points techniques de code et l'utilisation de logiciels pour la communication Multi - clients socket que vous utilisez habituellement
- Flexible layout (display:flex;) Attribute details
- The best time to buy and sell stocks
猜你喜欢
Experts' suggestions | 8 measures to accelerate your innovative career planning and growth
[Ocean University of China] Data Sharing for retest of initial Examination
中国电池技术取得重大突破,日韩美都落后了,中国巩固了领先优势
Shell string variable
JGG | 河北大学杜会龙组综述植物泛基因组学研究
Jaspersoft studio adding MySQL database configuration
当了六年程序员第一次搞懂微服务架构的数据一致性,真不容易
To make pytorch faster, you need to master these 17 methods
Thymeleaf Usage Summary
shell 变量 入门
随机推荐
弹性布局(display:flex;)属性详解
JS component
Open a restaurant
Cool assembly tutorial - concise x86 assembly language tutorial (1)
Where is it safe to open an account for buying funds? Ask for guidance
Mutationobserver listens for DOM changes
Gif动图如何裁剪?收下这个图片在线裁剪工具
Partager les points techniques de code et l'utilisation de logiciels pour la communication Multi - clients socket que vous utilisez habituellement
Extend JS copy content to clipboard
Position (5 ways)
shell 变量 入门
JS determines whether two values are equal, and compares any two values, including array objects
定位position(5种方式)
JS get the height and width corresponding to the box model (window.getcomputedstyle, dom.getboundingclientrect)
分享自己平时使用的socket多客户端通信的代码技术点和软件使用
[try to hack] vulhub shooting range construction
全国首例,中国电信 5G 井下人员定位项目正式商用:可实时跟踪位置,保障作业安全
Clinical Chemistry | 张建中/徐健开发幽门螺杆菌单细胞精准诊疗技术
买基金在哪里开户安全?求指导
Which is better and safer, GF easy gold rush or flush