ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

catkin workspaces are designed for building many packages together at once.

You can build a single package by using the standard CMake way of building:

mkdir build
cd build
cmake ..
make

The catkin workspace helps you by not only building multiple packages at once, but also by building you packages in the correct order. Consider that you have packages foo and bar where foo depended on bar. In a catkin workspace, catkin will automatically build bar before foo for you.

When creating new packages I would recommend making a catkin workspace first:

mkdir ~/my_catkin_ws
cd ~/my_catkin_ws

Then I would make a src (source) directory in my workspace and create the packages there:

mkdir src
cd src
catkin_create_package foo bar roscpp tf etc...

Now you would be able to build foo by running catkin_make:

cd ~/my_catkin_ws
source /opt/ros/groovy/setup.bash  # You should source the workspace which contains your dependent packages, often this will be in /opt/ros/groovy
catkin_make

Interestingly, catkin_make isn't doing anything fancy here. A catkin workspace is just a CMake project which can automatically find, include and use other packages. Because of this you can build a catkin workspace just like you can a single package:

cd ~/my_catkin_ws
cd src
catkin_init_workspace  # This creates a "top-level" CMakeLists.txt which collects and builds the packages in your workspace. Since this file is completely boiler plate this command just makes a symbolic link to the one provided by catkin
cd ..
mkdir build
cd build
cmake ../src  # Remember we put the source packages in that folder
make

catkin workspaces are designed for building many packages together at once.

You can build a single package by using the standard CMake way of building:

mkdir build
cd build
cmake ..
make

The catkin workspace helps you by not only building multiple packages at once, but also by building you packages in the correct order. Consider that you have packages foo foo and bar bar where foo foo depended on bar. bar. In a catkin workspace, catkin will automatically build bar before foo for you.

When creating new packages I would recommend making a catkin workspace first:

mkdir ~/my_catkin_ws
cd ~/my_catkin_ws

Then I would make a src (source) directory in my workspace and create the packages there:

mkdir src
cd src
catkin_create_package foo bar roscpp tf etc...

Now you would be able to build foo by running catkin_make:

cd ~/my_catkin_ws
source /opt/ros/groovy/setup.bash  # You should source the workspace which contains your dependent packages, the packages you depend on, often this will be in /opt/ros/groovy
catkin_make

Interestingly, catkin_make isn't doing anything fancy here. A catkin workspace is just a CMake project which can automatically find, include and use other packages. Because of this you can build a catkin workspace just like you can a single package:

cd ~/my_catkin_ws
cd src
catkin_init_workspace  # This creates a "top-level" CMakeLists.txt which collects and builds the packages in your workspace. Since this file is completely boiler plate this command just makes a symbolic link to the one provided by catkin
cd ..
mkdir build
cd build
cmake ../src  # Remember we put the source packages in that folder
make

catkin workspaces are designed for building many packages together at once.

You should put related packages in the same workspace rather than building them separately. You might, however, put packages in separate workspaces in order to have a smaller, faster building workspace. For instance, if you built all of the packages for ros-desktop in one workspace, and then you created your package foo in the same workspace, it might become cumbersome to rebuild that entire, large workspace each time you make a change to foo. So instead you can put foo in a different workspace which builds on that one, so then you only have to rebuild foo.


You can build a single package by using the standard CMake way of building:

mkdir build
cd build
cmake ..
make

The catkin workspace helps you by not only building multiple packages at once, but also by building you packages in the correct order. Consider that you have packages foo and bar where foo depended on bar. In a catkin workspace, catkin will automatically build bar before foo for you.

When creating new packages I would recommend making a catkin workspace first:

mkdir ~/my_catkin_ws
cd ~/my_catkin_ws

Then I would make a src (source) directory in my workspace and create the packages there:

mkdir src
cd src
catkin_create_package foo bar roscpp tf etc...

Now you would be able to build foo by running catkin_make:

cd ~/my_catkin_ws
source /opt/ros/groovy/setup.bash  # You should source the workspace which contains the packages you depend on, often this will be in /opt/ros/groovy
catkin_make

Interestingly, catkin_make isn't doing anything fancy here. A catkin workspace is just a CMake project which can automatically find, include and use other packages. Because of this you can build a catkin workspace just like you can a single package:

cd ~/my_catkin_ws
cd src
catkin_init_workspace  # This creates a "top-level" CMakeLists.txt which collects and builds the packages in your workspace. Since this file is completely boiler plate this command just makes a symbolic link to the one provided by catkin
cd ..
mkdir build
cd build
cmake ../src  # Remember we put the source packages in that folder
make