I was told that build dependency and runtime dependency are different. But I don't know why. If some dependency is necessary while building, can't we also say that it is necessary for running? If some dependency is necessary while running, can't we also say that it is necessary for building?
I'm learning the ROS and reading this link: http://wiki.ros.org/catkin/package.xml
I've found that there are <build_depend>
and <exec_depend>
, which surprised me because I was always thinking that build-depend and exec-depend were always the same...
Compiletime dependencies are only the dependencies (other classes) which you use directly in the class you're compiling. Runtime dependencies covers both the direct and indirect dependencies of the class you're running.
A dependency that can be resolved at compile time is a compile-time dependency. A dependency that cannot be resolved until runtime is a runtime dependency. Compile-time dependencies tend to be easier for developers to see than runtime dependencies, but sometimes runtime dependencies can be more flexible.
Before running your build command, the buildbot will look for instructions about required languages and software needed to run your command. These are called dependencies, and how you declare them depends on the languages and tools used in your build.
For many (I would say most) packages, if it is a dependency then it is both a build dependency and a runtime dependency. However, this is not always the case. A notable example is when you are creating new messages in your package, you include message_generation
as a build dependency, and message_runtime
as an execution dependency in package.xml:
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
This is because when you're building you want message_generation
for creating the header files for your message definition, but once they exist, you don't need the dependency to generate new messages at runtime - it only happens during the build process.
Likewise, message_runtime
handles runtime bindings of your message definitions, which isn't relevant for the build process itself.
These different dependency tags give you finer control over managing the dependencies. There is a catch-all tag <depend></depend>
that does not distinguish between these differences and can make your package.xml shorter if all your dependencies are both build and runtime dependencies.
This page gives an overview of the package.xml tags and relevant CMakeLists.txt info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With