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 ...
随机推荐
- Vector的小知识点
预留容量的两类方式: 1.不调用默认的构造函数 vector<int> v; v.push_back(111); v.reserve(20); std::copy(v.begin(), v ...
- 〖Python〗-- Django的Form组件
[Django的Form组件] Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次提交数据 初始化页面显示内容 Form类的使 ...
- 单例模式(Singleton)
单例模式 Singletonn Pattern Ensure a class has only one instance, and provide a global point of access ...
- python补充2
一 关于类中的self以及继承问题 请看下面一段代码 class Base: def f1(self): self.f2() def f2(self): print('...') class Foo( ...
- openStack 租户控制台修改虚拟机账户密码
- cloud-init方式 该种方式需要虚拟机镜像安装cloud-init,将重置密码脚本注入到虚拟机中.nova boot –image=image-id –nic net-id=net-id – ...
- zabbix微信报警
[root@LinuxS04 jiaoben]# ./weixin 联系人 baojing baojingok[root@LinuxS04 jiaoben]# pwd/usr/local/zabbix ...
- mybatis - maven - eclipse 坑爹问题: No suitable driver found for http://maven.apache.org
坑爹的问题,调查了1天 一直以为是驱动问题,根源却在url上:No suitable driver found for http://maven.apache.org 根源: 1.在jdbc.prop ...
- 字符串(string) 的基本操作
name = "my \tname is alex" #\t 空格 1. name.capitalize() #首字母大写 2.name.count('a') # 对字母a计数 ...
- python练习题:三级菜单
需求:可依次选择进入各子菜单可从任意一层往回退到上一层可从任意一层退出程序所需新知识点:列表.字典 测试环境:win7系统,python3.7.0,工具:pycharm-community-2018. ...
- Mysql 获取当月和上个月第一天和最后一天的解决方案
#获取当前日期select curdate(); #获取当月最后一天select last_day(curdate()): #获取本月的第一天select date_add(curdate(),int ...