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

How to build just one package using catkin_make?

asked 2013-02-04 00:39:58 -0600

TommyP gravatar image

updated 2020-11-21 11:14:07 -0600

lucasw gravatar image

How do I build just one package using catkin_make? I now that I can cd to the build directory and build there but that is inconvenient. And how do I build one package and its dependencies?

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted

answered 2013-09-03 23:32:09 -0600

fivef gravatar image

updated 2019-11-01 02:08:17 -0600

Build a single package including it's dependencies

catkin_make --only-pkg-with-deps <target_package>

Don't forget to switch back to building all packages when you are done



Whitelists only the specified packages and their dependencies by setting the CATKIN_WHITELIST_PACKAGES variable. This variable is stored in CMakeCache.txt and will persist between CMake calls unless explicitly cleared. Source: catkin_make --help

But there is an even better way

Using Catkin-Tools:

sudo apt-get install python-catkin-tools

Build specific package

catkin build <target_package>

Build the package from a directory under the package root

catkin build --this


  • you can call catkin build from everywhere
  • always builds packages seperately
  • catkin clean cleans everything (instead of the dangerous rm -rf build devel)
  • more infos

Important notes for catkin_tools:

  • You can't mix catkin build and catkin_make (delete your build/devel/install folders to switch tools)
  • As catkin_build builds all packages seperately there can be problems when passing information between packages via CMake. More Information

Old answer for legacy reasons

catkin_make --pkg <my_package_name>


catkin_make --pkg turtlebot

Multiple Packages:

catkin_make --pkg <package A> <package B>

But as this doesn't work robustly I recommend switching to catkin_tools which allows to build only one package and many more fancy features:

edit flag offensive delete link more



You can also use `--from-pkg <package>` to skip to that package and then continue building the workspace after that.

William gravatar image William  ( 2013-09-04 06:56:36 -0600 )edit

Is there any reason why I run this option and it keeps compiling everything within the catkin workspace?

Javier V. Gómez gravatar image Javier V. Gómez  ( 2013-11-22 02:44:10 -0600 )edit

Which option? If you mean the `--from-pkg <package>` option, if you specify the first package in the workspace then it will build them all. The idea is that it skips all packages which come before the one you specify, but builds that one package and all packages that follow it.

William gravatar image William  ( 2013-11-22 08:47:13 -0600 )edit

I personally feel this is an important thing that ought to to be mentioned in the tutorials.

McMurdo gravatar image McMurdo  ( 2014-01-07 02:36:57 -0600 )edit

I have the same problem as Javi V: I try to use this to make 1 package but it makes all the packages in the catkin_ws

edit: today it worked for reasons I don't understand.

korkor gravatar image korkor  ( 2015-05-05 07:14:14 -0600 )edit

I also occasionally try to use this trick and it rarely works. It just builds all of the packages still. I also can't tab complete my package.

shoemakerlevy9 gravatar image shoemakerlevy9  ( 2017-03-10 09:49:01 -0600 )edit

It did not worked for me either. catkin_make -DCATKIN_WHITELIST_PACKAGES="foo;bar" command worked.

burakaksoy gravatar image burakaksoy  ( 2018-11-26 18:53:16 -0600 )edit

How is this an accepted answer? It doesn't work.

Jägermeister gravatar image Jägermeister  ( 2019-08-05 04:50:52 -0600 )edit

answered 2013-02-04 01:23:07 -0600

KruseT gravatar image

Hi Tommy,

you can configure(!) a catkin workspace to only build one package using -DCATKIN_WHITELIST_PACKAGES

# "List of ';' separated packages to build"
catkin_make -DCATKIN_WHITELIST_PACKAGES="foo;bar"

This should really be documented in the docs and wiki. If you want to build more packages, you'd have to reconfigure.

Other than that, catkin relies on cmake, which generates targets named like the subfolders. So calling catkin_make <targetname> (or make <targetname> in a build folder) will make just this target, and all target it depends on.

Finally you can use catkin_build_isolated, which really invokes cmake+make for each package. It creates isolated build folders in which you can invoke make. If you#d like to suggest for catkin to provide for this in another way(such as an option to place the isolated build folders within the packagefolders, feel free to open an enhancement ticket on github.

edit flag offensive delete link more



Should catkin_make PACKAGE work, because for me it seems to do nothing?

dornhege gravatar image dornhege  ( 2013-02-04 01:49:44 -0600 )edit

I also have tested "catkin_make PACKAGE" and thought that that would work but it does not. That I could use "catkin_make TARGET" was not something I though about testing since I did not think it would work because of name collisions between targets. But it did work and can be very useful.

TommyP gravatar image TommyP  ( 2013-02-04 02:16:23 -0600 )edit

Wait, did it work for you or not?

dornhege gravatar image dornhege  ( 2013-02-04 02:53:48 -0600 )edit

No it does not. But e.g. "catkin_make mpinfo" were mpinfo is a target in the package lrs_quad works.

TommyP gravatar image TommyP  ( 2013-02-04 03:33:22 -0600 )edit

Doesn't work for me either. I'm not sure if it should. I don't want to hijack your question, so I described the problem here: - the solution might be related though.

dornhege gravatar image dornhege  ( 2013-02-04 04:05:27 -0600 )edit

This solution worked for me: catkin_make -DCATKIN_WHITELIST_PACKAGES=foo;bar

fabbro gravatar image fabbro  ( 2018-02-22 10:09:23 -0600 )edit

catkin_make -DCATKIN_WHITELIST_PACKAGES="foo;bar" works fine but be aware that you will have to run catkin_make -DCATKIN_WHITELIST_PACKAGES="" to be able to build all your packages again. Also catkin_make -DCATKIN_BLACKLIST_PACKAGES="foo;bar" can be useful not to build some packages.

Delb gravatar image Delb  ( 2018-02-23 03:19:25 -0600 )edit

Hi Delb, thanks for that extra comment about building all packages again. The same thing may be said about blacklisted packages ( if you have a blacklisted package, just setting whitelisted = "" doesn't work... you will need to set blacklisted="" as well,, or remove it from blacklisted list somehow)

malharjajoo gravatar image malharjajoo  ( 2018-06-05 16:38:13 -0600 )edit

answered 2019-05-29 21:31:21 -0600

Rufus gravatar image

updated 2019-05-29 21:34:42 -0600

The aforementioned answers are incorrect, --pkg still includes all packages as documented here which means if some untargeted package have unmet dependencies, the build will fail.

CATKIN_WHITELIST_PACKAGE does not correctly build dependent packages of the whitelisted package

The proper way is catkin_make --only-pkg-with-deps <target_package>

edit flag offensive delete link more


This command worked for me. The currently selected answer, catkin_make --pkg <package A> did not, as others noted it built all packages.

bakerhillpins gravatar image bakerhillpins  ( 2019-06-21 08:29:01 -0600 )edit

answered 2016-08-16 06:06:25 -0600

user23fj239 gravatar image

updated 2016-08-16 06:07:34 -0600

Add this to your CMakeLists.txt :

# switch it ON or OFF depending on what you want

# paste your CMakeLists text here


Another solution:
put an empty file with the name CATKIN_IGNORE into the package directory.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-02-04 00:39:58 -0600

Seen: 110,715 times

Last updated: Nov 01 '19