catkin_make 与cmake
http://blog.csdn.net/zyh821351004/article/details/50388429
1. catkin_make 与cmake的关系
程序在cmake编译的流程: cmake指令依据你的CMakeLists.txt 文件,生成makefiles文件,make再依据此makefiles文件编译链接生成可执行文件.
catkin_make是将cmake与make的编译方式做了一个封装的指令工具, 规范了工作路径与生成文件路径.
1) cmake标准流程
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install # (可选)
2) catkin_make 的流程
# In a catkin workspace
$ catkin_make
$ catkin_make install # (可选)
如果源码不在默认工作空间,需要指定编译路径: # In a catkin workspace
$ catkin_make --source my_src
$ catkin_make install --source my_src # (optionally)
2. catkin_make
1) catkin_make默认的路径信息
catkin_make运行后终端输出文件部分解析 #基本路径
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install #catkin_make 封装运行中cmake运行的情况
Running command: "cmake /home/user/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/user/catkin_ws/devel
-DCMAKE_INSTALL_PREFIX=/home/user/catkin_ws/install" in "/home/user/catkin_ws/build" #编译工具查找
-- Using CATKIN_DEVEL_PREFIX: /tmp/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/groovy
-- This workspace overlays: /opt/ros/groovy #编译的包
<pre name="code" class="cpp">#catkin_make 封装运行中make运行的情况
#### Running command: "make -j4" in "/home/user/catkin_ws/build"
2) layout :ros工作空间文件系统结构
workspace_folder/ --WORKSPACE 工作空间
src/ --SOURCE SPACE 源空间
CMakeLists.txt/ --This is symlinked to catkin/cmake/toplevel.cmake
package_1/
CMakeLists.txt
package.xml
...
package_n/
CMakeLists.txt
package.xml
build/ --BUILD SPACE 编译空间 (this is where build system is invoked, not necessarily within workspace)
CATKIN_IGNORE --Marking the folder to be ignored when crawling for packages (necessary when source
space is in the root of the workspace, the file is emtpy)
#此选项可用于忽略某个包编译
devel/ --DEVEL SPACE 开发空间(targets go here, parameterizable, but defaults to peer of Build Space)
# 生成二值 库 可执行文件
bin/
etc/
/include/
lib/
share/
.catkin --Marking the folder as a development space (the file contains a semicolon separated list of Source space paths)
#
env.bash
setup.bash
setup.sh
...
install/ --INSTALL SPACE 安装空间[-DCMAKE_INSTALL_PREFIX=/any/directorycmake默认是/usr/local](this is where installed targets for test installations go, not necessarily within workspace)
bin/
etc/
include/
lib/
share/
.catkin --Marking the folder as an install space (the file is emtpy)
env.bash
setup.bash -- Environment setup file for Bash shell
setup.sh -- Environment setup file for Bourne shell
... / 系统安装空间 /opt/ros/ROSDISTRO
opt/
ros/
groovy/
setup.bash -- Environment setup file for Bash shell
setup.sh -- Environment setup file for Bourne shell
setup.zsh -- Environment setup file for zshell
... 结果空间 source RESULT-SPACE/setup.sh 类似扫描安装空间与开发空间,替换系统通用下的对应文件.
总结:
src/ --SOURCE SPACE 源空间
build/ --BUILD SPACE 编译空间
devel/ --DEVEL SPACE 开发空间
install/ --INSTALL SPACE 安装空间
ROS系统安装空间 /opt/ros/indigo
3)Overlays
catkin支持包的逐层覆盖, 当前最高,其它依据source的顺序逐层变高, 高层可覆盖低层.
Example : Overlaying workspace on top of local workspace2 install space on top of workspace1 devel space on top of system install cd ~/workspace2/build
cmake -DCMAKE_INSTALL_PREFIX=~/ws2_installed ../src
make
make install source ~/ws2_installed/setup.bash cd ~/workspace3/build
cmake ../src
make
ros 环境变量设置 可以参考.bashrc文件
# slam_ws
source /opt/ros/indigo/setup.bash
source /home/yhzhao/slam_ws/devel/setup.bash export ROS_PACKAGE_PATH=~/slam_ws/src:$ROS_PACKAGE_PATH
export ROS_WORKSPACE=~/slam_ws/src
4) catkin_make编译指定的包
$ catkin_make -DCATKIN_WHITELIST_PACKAGES="package1;package2"
恢复编译所有的包
$ catkin_make -DCATKIN_WHITELIST_PACKAGES=""
3. 对这句命令进行解释:
catkin build rovio --cmake-args -DCMAKE_BUILD_TYPE=Release -DMAKE_SCENE=ON
catkin build – Build Packages,编译rovio包
如果工作空间未初始化,可以自动完成工作空间初始化 (source ~/catkin_ws/devel/setup.bash)
It is used to build one or more packages in a catkin workspace. If a workspace is not yet initialized(初始化), build can initialize it with the default configuration(默认配置), but only if it is called from the workspace root. Specific workspaces can also be built from arbitrary working directories with the --workspace option.
--cmake-args #cmake参数
-DCMAKE_BUILD_TYPE=Release
使用 CMake我们可以生成 debug 版和 release 版的程序。debug 版的项目生成的可执行文件需要有调试信息并且不需要进行优化,而 release 版的不需要调试信息但需要优化。这些特性在 gcc/g++ 中是通过编译时的参数来决定的,如果将优化程度调到最高需要设置参数-O3,最低是 -O0 即不做优化;添加调试信息的参数是 -g -ggdb ,如果不添加这个参数,调试信息就不会被包含在生成的二进制文件中。
CMake 中有一个变量 CMAKE_BUILD_TYPE ,可以的取值是 Debug、 Release、 RelWithDebInfo 和 MinSizeRel。当这个变量值为 Debug 的时候,CMake 会使用变量 CMAKE_CXX_FLAGS_DEBUG 和 CMAKE_C_FLAGS_DEBUG 中的字符串作为编译选项生成 Makefile ,当这个变量值为 Release 的时候,工程会使用变量 CMAKE_CXX_FLAGS_RELEASE 和 CMAKE_C_FLAGS_RELEASE 选项生成 Makefile。
现假设项目中只有一个文件 main.cpp ,下面是一个可以选择生成 debug 版和 release 版的程序的 CMakeList.txt :
PROJECT(main)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CMAKE_SOURCE_DIR .)
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
AUX_SOURCE_DIRECTORY(. DIR_SRCS)
ADD_EXECUTABLE(main ${DIR_SRCS})
catkin_make 与cmake的更多相关文章
- make cmake catkin_make
在Linux下进行C语言编程,必然要采用GNU GCC来编译C源代码生成可执行程序. 一.GCC快速入门 Gcc指令的一般格式为:Gcc [选项] 要编译的文件 [选项] [目标文件] 其中,目标文件 ...
- ROS编译:catkin简析
博客转载自:https://blog.csdn.net/zyh821351004/article/details/50388429 Catkin tutorials: http://wiki.ros. ...
- eclipse+cmake+c++11+ros
eclipse+cmake: https://www.vtk.org/Wiki/CMake:Eclipse_UNIX_Tutorial eclipse+c++11: https://wiki.ecli ...
- 删除某个ros包之后catkin_make冒错
CMake Error at /home/ubuntu/Workspaces/rosProject/workspace1/devel/share/costmap_2d/cmake/costmap_2d ...
- CMake error:System Error:No such file or directory CMake error:Could not open file for write in copy operation xxxx.ros_Config.cmake.tmp.
微型电脑或嵌入式与电脑还是有点不同的,在微型电脑上ros indigo 版本下利用catkin编译如果你遇到如下错误: CMake error:System Error:No such file or ...
- ros结合catkin_make和qtcreator
首先是ros官网关于IDE的教程: http://wiki.ros.org/IDEs#QtCreator 1.qtcreator安装 从官网上下载.run文件, https://info.qt.io/ ...
- ROS catkin_make error Could not find a package configuration file provided by "actionlib_msgs"
在使用ROS catkin_make编译的时候,出现类似如下错误 CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cma ...
- Learning ROS: Ubuntu16.04下kinetic开发环境安装和初体验 Install + Configure + Navigating(look around) + Creating a Package(catkin_create_pkg) + Building a Package(catkin_make) + Understanding Nodes
本文主要部分来源于ROS官网的Tutorials. Ubuntu install of ROS Kinetic # Setup your sources.list sudo sh -c 'echo & ...
- 使用cmake自动构建工程
公司引擎是用cmake根据目标平台来构建工程的,刚接触的时候深深体会到cmake的方便:如果目标平台是windows,它可以帮你自动构建出vs工程:如果是安卓,自动构建出eclipse工程,如果是IO ...
随机推荐
- 解决Sublime 3提示 Sublime Text Error while loading PyV8 binary
转自:http://blog.initm.com/sublime-text/ 今天打开sublime遇到一个提示 如上图Sublime Text Error while loading PyV8 b ...
- css border
CSS border用于设置HTML元素(如div)的边框,包括边框的宽度.颜色和样式.本文章向码农介绍CSS border边框属性详细内容,感兴趣的码农可以参考一下. CSS 边框即CSS bord ...
- Solr学习之二-Solr基础知识
一 基本说明 简单来说Solr是基于Lucene的高性能的,开源的Java企业搜索服务器.Solr可以看作一个Web app,运行在tomcat或Jetty这类HTTP服务器上, 底层是一个基于Luc ...
- css position小结
relative:可使top,right,bottom,left等相对于自身位置来进行偏移:若无则这些偏移都不会起作用 absolute:寻找离自己最近position为relative或absolu ...
- 装饰模式 (Decoratory)
动态地给一个对象添加一些额外的职责,就增加功能来说,装饰模式比生成子类更灵活. 装饰模式就是利用 SetComponent 来对对象进行包装的,这样每个装饰对象的实现就和如何使用这个对象分离开了,每个 ...
- 20180201之Burp Suite Professional V1.7.31 相关英文翻译
Burp Suite Professional V1.7.31 打嗝 套件 专业
- 框架之Tornado(简单介绍)
引言 回想Django的部署方式 以Django为代表的python web应用部署时采用wsgi协议与服务器对接(被服务器托管),而这类服务器通常都是基于多线程的,也就是说每一个网络请求服务器都会有 ...
- npm WARN react-native-maps@0.14.0 requires a peer of react@>=15.4.0 but none was installed
install the react-native here comes a questions :: npm WARN react-native@0.41.2 requires a pe ...
- maven 在pom.xml 中指定仓库位置
...... 在pom.xml 中添加 仓库位置(这样遇到私服没有的依赖,就会去这下载) </properties> <repositories><!-- 代码库 --& ...
- JAVA Spring 事物 ( 已转账为例 ) 基于 XML 配置,事务类型说明
< 1 > 配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=&q ...