Executable built from multiple source files? [closed]
Hello, I am working on setting up a robot I have in ROS, using ROS drivers written by others. Specifically, I'm using an LMS151 laser scanner and an ax2550 motor controller, with the drivers found here:
https://github.com/clearpathrobotics/... https://github.com/wjwwood/ax2550
While inspecting the code inside these projects, I noticed that they both have a similar format: a cpp file labeled <device>.cpp, and another labeled <device>_node.cpp. Then they both build their executable from both cpp files, using the line
add_executable(<device>_node src/<device>_node.cpp src/<device>.cpp),
which is what I don't understand. How does building one executable from two files work? How does the compiler combine the two into one program? It must somehow work, because both of the authors do it, and I've gotten one of the nodes (the LMS1xx one to work already), but I don't understand how.
As an aside, even the simple ros hello-world talker/listener is not just one source file. In the true spirit it is at least 2-3 source files. The only difference is that here they have been already compiled and put into a nice shared object and you simply link them with your program.